001    /**
002     * Copyright (c) 2000-2012 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.NoSuchModelException;
018    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
019    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
020    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderPath;
022    import com.liferay.portal.kernel.dao.orm.Query;
023    import com.liferay.portal.kernel.dao.orm.QueryPos;
024    import com.liferay.portal.kernel.dao.orm.QueryUtil;
025    import com.liferay.portal.kernel.dao.orm.SQLQuery;
026    import com.liferay.portal.kernel.dao.orm.Session;
027    import com.liferay.portal.kernel.exception.SystemException;
028    import com.liferay.portal.kernel.log.Log;
029    import com.liferay.portal.kernel.log.LogFactoryUtil;
030    import com.liferay.portal.kernel.util.ArrayUtil;
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.StringBundler;
035    import com.liferay.portal.kernel.util.StringPool;
036    import com.liferay.portal.kernel.util.StringUtil;
037    import com.liferay.portal.kernel.util.UnmodifiableList;
038    import com.liferay.portal.kernel.util.Validator;
039    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
040    import com.liferay.portal.model.CacheModel;
041    import com.liferay.portal.model.ModelListener;
042    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
043    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
044    
045    import com.liferay.portlet.journal.NoSuchArticleException;
046    import com.liferay.portlet.journal.model.JournalArticle;
047    import com.liferay.portlet.journal.model.impl.JournalArticleImpl;
048    import com.liferay.portlet.journal.model.impl.JournalArticleModelImpl;
049    
050    import java.io.Serializable;
051    
052    import java.util.ArrayList;
053    import java.util.Collections;
054    import java.util.List;
055    
056    /**
057     * The persistence implementation for the journal article service.
058     *
059     * <p>
060     * Caching information and settings can be found in <code>portal.properties</code>
061     * </p>
062     *
063     * @author Brian Wing Shun Chan
064     * @see JournalArticlePersistence
065     * @see JournalArticleUtil
066     * @generated
067     */
068    public class JournalArticlePersistenceImpl extends BasePersistenceImpl<JournalArticle>
069            implements JournalArticlePersistence {
070            /*
071             * NOTE FOR DEVELOPERS:
072             *
073             * 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.
074             */
075            public static final String FINDER_CLASS_NAME_ENTITY = JournalArticleImpl.class.getName();
076            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077                    ".List1";
078            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
079                    ".List2";
080            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
081                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
082                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
083                            "findAll", new String[0]);
084            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
085                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
086                            JournalArticleImpl.class,
087                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
088            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
089                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
090                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
091            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
092                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
093                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
094                            "findByUuid",
095                            new String[] {
096                                    String.class.getName(),
097                                    
098                            Integer.class.getName(), Integer.class.getName(),
099                                    OrderByComparator.class.getName()
100                            });
101            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
102                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
103                            JournalArticleImpl.class,
104                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
105                            new String[] { String.class.getName() },
106                            JournalArticleModelImpl.UUID_COLUMN_BITMASK |
107                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
108                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
109            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
110                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
111                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
112                            new String[] { String.class.getName() });
113    
114            /**
115             * Returns all the journal articles where uuid = &#63;.
116             *
117             * @param uuid the uuid
118             * @return the matching journal articles
119             * @throws SystemException if a system exception occurred
120             */
121            public List<JournalArticle> findByUuid(String uuid)
122                    throws SystemException {
123                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
124            }
125    
126            /**
127             * Returns a range of all the journal articles where uuid = &#63;.
128             *
129             * <p>
130             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
131             * </p>
132             *
133             * @param uuid the uuid
134             * @param start the lower bound of the range of journal articles
135             * @param end the upper bound of the range of journal articles (not inclusive)
136             * @return the range of matching journal articles
137             * @throws SystemException if a system exception occurred
138             */
139            public List<JournalArticle> findByUuid(String uuid, int start, int end)
140                    throws SystemException {
141                    return findByUuid(uuid, start, end, null);
142            }
143    
144            /**
145             * Returns an ordered range of all the journal articles where uuid = &#63;.
146             *
147             * <p>
148             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
149             * </p>
150             *
151             * @param uuid the uuid
152             * @param start the lower bound of the range of journal articles
153             * @param end the upper bound of the range of journal articles (not inclusive)
154             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
155             * @return the ordered range of matching journal articles
156             * @throws SystemException if a system exception occurred
157             */
158            public List<JournalArticle> findByUuid(String uuid, int start, int end,
159                    OrderByComparator orderByComparator) throws SystemException {
160                    boolean pagination = true;
161                    FinderPath finderPath = null;
162                    Object[] finderArgs = null;
163    
164                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
165                                    (orderByComparator == null)) {
166                            pagination = false;
167                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
168                            finderArgs = new Object[] { uuid };
169                    }
170                    else {
171                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
172                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
173                    }
174    
175                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
176                                    finderArgs, this);
177    
178                    if ((list != null) && !list.isEmpty()) {
179                            for (JournalArticle journalArticle : list) {
180                                    if (!Validator.equals(uuid, journalArticle.getUuid())) {
181                                            list = null;
182    
183                                            break;
184                                    }
185                            }
186                    }
187    
188                    if (list == null) {
189                            StringBundler query = null;
190    
191                            if (orderByComparator != null) {
192                                    query = new StringBundler(3 +
193                                                    (orderByComparator.getOrderByFields().length * 3));
194                            }
195                            else {
196                                    query = new StringBundler(3);
197                            }
198    
199                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
200    
201                            if (uuid == null) {
202                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
203                            }
204                            else {
205                                    if (uuid.equals(StringPool.BLANK)) {
206                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
207                                    }
208                                    else {
209                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
210                                    }
211                            }
212    
213                            if (orderByComparator != null) {
214                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
215                                            orderByComparator);
216                            }
217                            else
218                             if (pagination) {
219                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
220                            }
221    
222                            String sql = query.toString();
223    
224                            Session session = null;
225    
226                            try {
227                                    session = openSession();
228    
229                                    Query q = session.createQuery(sql);
230    
231                                    QueryPos qPos = QueryPos.getInstance(q);
232    
233                                    if (uuid != null) {
234                                            qPos.add(uuid);
235                                    }
236    
237                                    if (!pagination) {
238                                            list = (List<JournalArticle>)QueryUtil.list(q,
239                                                            getDialect(), start, end, false);
240    
241                                            Collections.sort(list);
242    
243                                            list = new UnmodifiableList<JournalArticle>(list);
244                                    }
245                                    else {
246                                            list = (List<JournalArticle>)QueryUtil.list(q,
247                                                            getDialect(), start, end);
248                                    }
249    
250                                    cacheResult(list);
251    
252                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
253                            }
254                            catch (Exception e) {
255                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
256    
257                                    throw processException(e);
258                            }
259                            finally {
260                                    closeSession(session);
261                            }
262                    }
263    
264                    return list;
265            }
266    
267            /**
268             * Returns the first journal article in the ordered set where uuid = &#63;.
269             *
270             * @param uuid the uuid
271             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
272             * @return the first matching journal article
273             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
274             * @throws SystemException if a system exception occurred
275             */
276            public JournalArticle findByUuid_First(String uuid,
277                    OrderByComparator orderByComparator)
278                    throws NoSuchArticleException, SystemException {
279                    JournalArticle journalArticle = fetchByUuid_First(uuid,
280                                    orderByComparator);
281    
282                    if (journalArticle != null) {
283                            return journalArticle;
284                    }
285    
286                    StringBundler msg = new StringBundler(4);
287    
288                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
289    
290                    msg.append("uuid=");
291                    msg.append(uuid);
292    
293                    msg.append(StringPool.CLOSE_CURLY_BRACE);
294    
295                    throw new NoSuchArticleException(msg.toString());
296            }
297    
298            /**
299             * Returns the first journal article in the ordered set where uuid = &#63;.
300             *
301             * @param uuid the uuid
302             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
303             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
304             * @throws SystemException if a system exception occurred
305             */
306            public JournalArticle fetchByUuid_First(String uuid,
307                    OrderByComparator orderByComparator) throws SystemException {
308                    List<JournalArticle> list = findByUuid(uuid, 0, 1, orderByComparator);
309    
310                    if (!list.isEmpty()) {
311                            return list.get(0);
312                    }
313    
314                    return null;
315            }
316    
317            /**
318             * Returns the last journal article in the ordered set where uuid = &#63;.
319             *
320             * @param uuid the uuid
321             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
322             * @return the last matching journal article
323             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
324             * @throws SystemException if a system exception occurred
325             */
326            public JournalArticle findByUuid_Last(String uuid,
327                    OrderByComparator orderByComparator)
328                    throws NoSuchArticleException, SystemException {
329                    JournalArticle journalArticle = fetchByUuid_Last(uuid, orderByComparator);
330    
331                    if (journalArticle != null) {
332                            return journalArticle;
333                    }
334    
335                    StringBundler msg = new StringBundler(4);
336    
337                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
338    
339                    msg.append("uuid=");
340                    msg.append(uuid);
341    
342                    msg.append(StringPool.CLOSE_CURLY_BRACE);
343    
344                    throw new NoSuchArticleException(msg.toString());
345            }
346    
347            /**
348             * Returns the last journal article in the ordered set where uuid = &#63;.
349             *
350             * @param uuid the uuid
351             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
352             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
353             * @throws SystemException if a system exception occurred
354             */
355            public JournalArticle fetchByUuid_Last(String uuid,
356                    OrderByComparator orderByComparator) throws SystemException {
357                    int count = countByUuid(uuid);
358    
359                    List<JournalArticle> list = findByUuid(uuid, count - 1, count,
360                                    orderByComparator);
361    
362                    if (!list.isEmpty()) {
363                            return list.get(0);
364                    }
365    
366                    return null;
367            }
368    
369            /**
370             * Returns the journal articles before and after the current journal article in the ordered set where uuid = &#63;.
371             *
372             * @param id the primary key of the current journal article
373             * @param uuid the uuid
374             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
375             * @return the previous, current, and next journal article
376             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
377             * @throws SystemException if a system exception occurred
378             */
379            public JournalArticle[] findByUuid_PrevAndNext(long id, String uuid,
380                    OrderByComparator orderByComparator)
381                    throws NoSuchArticleException, SystemException {
382                    JournalArticle journalArticle = findByPrimaryKey(id);
383    
384                    Session session = null;
385    
386                    try {
387                            session = openSession();
388    
389                            JournalArticle[] array = new JournalArticleImpl[3];
390    
391                            array[0] = getByUuid_PrevAndNext(session, journalArticle, uuid,
392                                            orderByComparator, true);
393    
394                            array[1] = journalArticle;
395    
396                            array[2] = getByUuid_PrevAndNext(session, journalArticle, uuid,
397                                            orderByComparator, false);
398    
399                            return array;
400                    }
401                    catch (Exception e) {
402                            throw processException(e);
403                    }
404                    finally {
405                            closeSession(session);
406                    }
407            }
408    
409            protected JournalArticle getByUuid_PrevAndNext(Session session,
410                    JournalArticle journalArticle, String uuid,
411                    OrderByComparator orderByComparator, boolean previous) {
412                    StringBundler query = null;
413    
414                    if (orderByComparator != null) {
415                            query = new StringBundler(6 +
416                                            (orderByComparator.getOrderByFields().length * 6));
417                    }
418                    else {
419                            query = new StringBundler(3);
420                    }
421    
422                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
423    
424                    if (uuid == null) {
425                            query.append(_FINDER_COLUMN_UUID_UUID_1);
426                    }
427                    else {
428                            if (uuid.equals(StringPool.BLANK)) {
429                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
430                            }
431                            else {
432                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
433                            }
434                    }
435    
436                    if (orderByComparator != null) {
437                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
438    
439                            if (orderByConditionFields.length > 0) {
440                                    query.append(WHERE_AND);
441                            }
442    
443                            for (int i = 0; i < orderByConditionFields.length; i++) {
444                                    query.append(_ORDER_BY_ENTITY_ALIAS);
445                                    query.append(orderByConditionFields[i]);
446    
447                                    if ((i + 1) < orderByConditionFields.length) {
448                                            if (orderByComparator.isAscending() ^ previous) {
449                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
450                                            }
451                                            else {
452                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
453                                            }
454                                    }
455                                    else {
456                                            if (orderByComparator.isAscending() ^ previous) {
457                                                    query.append(WHERE_GREATER_THAN);
458                                            }
459                                            else {
460                                                    query.append(WHERE_LESSER_THAN);
461                                            }
462                                    }
463                            }
464    
465                            query.append(ORDER_BY_CLAUSE);
466    
467                            String[] orderByFields = orderByComparator.getOrderByFields();
468    
469                            for (int i = 0; i < orderByFields.length; i++) {
470                                    query.append(_ORDER_BY_ENTITY_ALIAS);
471                                    query.append(orderByFields[i]);
472    
473                                    if ((i + 1) < orderByFields.length) {
474                                            if (orderByComparator.isAscending() ^ previous) {
475                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
476                                            }
477                                            else {
478                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
479                                            }
480                                    }
481                                    else {
482                                            if (orderByComparator.isAscending() ^ previous) {
483                                                    query.append(ORDER_BY_ASC);
484                                            }
485                                            else {
486                                                    query.append(ORDER_BY_DESC);
487                                            }
488                                    }
489                            }
490                    }
491                    else {
492                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
493                    }
494    
495                    String sql = query.toString();
496    
497                    Query q = session.createQuery(sql);
498    
499                    q.setFirstResult(0);
500                    q.setMaxResults(2);
501    
502                    QueryPos qPos = QueryPos.getInstance(q);
503    
504                    if (uuid != null) {
505                            qPos.add(uuid);
506                    }
507    
508                    if (orderByComparator != null) {
509                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
510    
511                            for (Object value : values) {
512                                    qPos.add(value);
513                            }
514                    }
515    
516                    List<JournalArticle> list = q.list();
517    
518                    if (list.size() == 2) {
519                            return list.get(1);
520                    }
521                    else {
522                            return null;
523                    }
524            }
525    
526            /**
527             * Removes all the journal articles where uuid = &#63; from the database.
528             *
529             * @param uuid the uuid
530             * @throws SystemException if a system exception occurred
531             */
532            public void removeByUuid(String uuid) throws SystemException {
533                    for (JournalArticle journalArticle : findByUuid(uuid,
534                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
535                            remove(journalArticle);
536                    }
537            }
538    
539            /**
540             * Returns the number of journal articles where uuid = &#63;.
541             *
542             * @param uuid the uuid
543             * @return the number of matching journal articles
544             * @throws SystemException if a system exception occurred
545             */
546            public int countByUuid(String uuid) throws SystemException {
547                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
548    
549                    Object[] finderArgs = new Object[] { uuid };
550    
551                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
552                                    this);
553    
554                    if (count == null) {
555                            StringBundler query = new StringBundler(2);
556    
557                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
558    
559                            if (uuid == null) {
560                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
561                            }
562                            else {
563                                    if (uuid.equals(StringPool.BLANK)) {
564                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
565                                    }
566                                    else {
567                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
568                                    }
569                            }
570    
571                            String sql = query.toString();
572    
573                            Session session = null;
574    
575                            try {
576                                    session = openSession();
577    
578                                    Query q = session.createQuery(sql);
579    
580                                    QueryPos qPos = QueryPos.getInstance(q);
581    
582                                    if (uuid != null) {
583                                            qPos.add(uuid);
584                                    }
585    
586                                    count = (Long)q.uniqueResult();
587    
588                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
589                            }
590                            catch (Exception e) {
591                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
592    
593                                    throw processException(e);
594                            }
595                            finally {
596                                    closeSession(session);
597                            }
598                    }
599    
600                    return count.intValue();
601            }
602    
603            private static final String _FINDER_COLUMN_UUID_UUID_1 = "journalArticle.uuid IS NULL";
604            private static final String _FINDER_COLUMN_UUID_UUID_2 = "journalArticle.uuid = ?";
605            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = ?)";
606            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
607                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
608                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY,
609                            "fetchByUUID_G",
610                            new String[] { String.class.getName(), Long.class.getName() },
611                            JournalArticleModelImpl.UUID_COLUMN_BITMASK |
612                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK);
613            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
614                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
615                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
616                            new String[] { String.class.getName(), Long.class.getName() });
617    
618            /**
619             * 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.
620             *
621             * @param uuid the uuid
622             * @param groupId the group ID
623             * @return the matching journal article
624             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
625             * @throws SystemException if a system exception occurred
626             */
627            public JournalArticle findByUUID_G(String uuid, long groupId)
628                    throws NoSuchArticleException, SystemException {
629                    JournalArticle journalArticle = fetchByUUID_G(uuid, groupId);
630    
631                    if (journalArticle == null) {
632                            StringBundler msg = new StringBundler(6);
633    
634                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
635    
636                            msg.append("uuid=");
637                            msg.append(uuid);
638    
639                            msg.append(", groupId=");
640                            msg.append(groupId);
641    
642                            msg.append(StringPool.CLOSE_CURLY_BRACE);
643    
644                            if (_log.isWarnEnabled()) {
645                                    _log.warn(msg.toString());
646                            }
647    
648                            throw new NoSuchArticleException(msg.toString());
649                    }
650    
651                    return journalArticle;
652            }
653    
654            /**
655             * 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.
656             *
657             * @param uuid the uuid
658             * @param groupId the group ID
659             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
660             * @throws SystemException if a system exception occurred
661             */
662            public JournalArticle fetchByUUID_G(String uuid, long groupId)
663                    throws SystemException {
664                    return fetchByUUID_G(uuid, groupId, true);
665            }
666    
667            /**
668             * 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.
669             *
670             * @param uuid the uuid
671             * @param groupId the group ID
672             * @param retrieveFromCache whether to use the finder cache
673             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
674             * @throws SystemException if a system exception occurred
675             */
676            public JournalArticle fetchByUUID_G(String uuid, long groupId,
677                    boolean retrieveFromCache) throws SystemException {
678                    Object[] finderArgs = new Object[] { uuid, groupId };
679    
680                    Object result = null;
681    
682                    if (retrieveFromCache) {
683                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
684                                            finderArgs, this);
685                    }
686    
687                    if (result instanceof JournalArticle) {
688                            JournalArticle journalArticle = (JournalArticle)result;
689    
690                            if (!Validator.equals(uuid, journalArticle.getUuid()) ||
691                                            (groupId != journalArticle.getGroupId())) {
692                                    result = null;
693                            }
694                    }
695    
696                    if (result == null) {
697                            StringBundler query = new StringBundler(4);
698    
699                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
700    
701                            if (uuid == null) {
702                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
703                            }
704                            else {
705                                    if (uuid.equals(StringPool.BLANK)) {
706                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
707                                    }
708                                    else {
709                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
710                                    }
711                            }
712    
713                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
714    
715                            String sql = query.toString();
716    
717                            Session session = null;
718    
719                            try {
720                                    session = openSession();
721    
722                                    Query q = session.createQuery(sql);
723    
724                                    QueryPos qPos = QueryPos.getInstance(q);
725    
726                                    if (uuid != null) {
727                                            qPos.add(uuid);
728                                    }
729    
730                                    qPos.add(groupId);
731    
732                                    List<JournalArticle> list = q.list();
733    
734                                    if (list.isEmpty()) {
735                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
736                                                    finderArgs, list);
737                                    }
738                                    else {
739                                            JournalArticle journalArticle = list.get(0);
740    
741                                            result = journalArticle;
742    
743                                            cacheResult(journalArticle);
744    
745                                            if ((journalArticle.getUuid() == null) ||
746                                                            !journalArticle.getUuid().equals(uuid) ||
747                                                            (journalArticle.getGroupId() != groupId)) {
748                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
749                                                            finderArgs, journalArticle);
750                                            }
751                                    }
752                            }
753                            catch (Exception e) {
754                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
755                                            finderArgs);
756    
757                                    throw processException(e);
758                            }
759                            finally {
760                                    closeSession(session);
761                            }
762                    }
763    
764                    if (result instanceof List<?>) {
765                            return null;
766                    }
767                    else {
768                            return (JournalArticle)result;
769                    }
770            }
771    
772            /**
773             * Removes the journal article where uuid = &#63; and groupId = &#63; from the database.
774             *
775             * @param uuid the uuid
776             * @param groupId the group ID
777             * @return the journal article that was removed
778             * @throws SystemException if a system exception occurred
779             */
780            public JournalArticle removeByUUID_G(String uuid, long groupId)
781                    throws NoSuchArticleException, SystemException {
782                    JournalArticle journalArticle = findByUUID_G(uuid, groupId);
783    
784                    return remove(journalArticle);
785            }
786    
787            /**
788             * Returns the number of journal articles where uuid = &#63; and groupId = &#63;.
789             *
790             * @param uuid the uuid
791             * @param groupId the group ID
792             * @return the number of matching journal articles
793             * @throws SystemException if a system exception occurred
794             */
795            public int countByUUID_G(String uuid, long groupId)
796                    throws SystemException {
797                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
798    
799                    Object[] finderArgs = new Object[] { uuid, groupId };
800    
801                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
802                                    this);
803    
804                    if (count == null) {
805                            StringBundler query = new StringBundler(3);
806    
807                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
808    
809                            if (uuid == null) {
810                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
811                            }
812                            else {
813                                    if (uuid.equals(StringPool.BLANK)) {
814                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
815                                    }
816                                    else {
817                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
818                                    }
819                            }
820    
821                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
822    
823                            String sql = query.toString();
824    
825                            Session session = null;
826    
827                            try {
828                                    session = openSession();
829    
830                                    Query q = session.createQuery(sql);
831    
832                                    QueryPos qPos = QueryPos.getInstance(q);
833    
834                                    if (uuid != null) {
835                                            qPos.add(uuid);
836                                    }
837    
838                                    qPos.add(groupId);
839    
840                                    count = (Long)q.uniqueResult();
841    
842                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
843                            }
844                            catch (Exception e) {
845                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
846    
847                                    throw processException(e);
848                            }
849                            finally {
850                                    closeSession(session);
851                            }
852                    }
853    
854                    return count.intValue();
855            }
856    
857            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "journalArticle.uuid IS NULL AND ";
858            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "journalArticle.uuid = ? AND ";
859            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = ?) AND ";
860            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "journalArticle.groupId = ?";
861            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
862                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
863                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
864                            "findByUuid_C",
865                            new String[] {
866                                    String.class.getName(), Long.class.getName(),
867                                    
868                            Integer.class.getName(), Integer.class.getName(),
869                                    OrderByComparator.class.getName()
870                            });
871            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
872                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
873                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
874                            JournalArticleImpl.class,
875                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
876                            new String[] { String.class.getName(), Long.class.getName() },
877                            JournalArticleModelImpl.UUID_COLUMN_BITMASK |
878                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
879                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
880                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
881            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
882                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
883                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
884                            new String[] { String.class.getName(), Long.class.getName() });
885    
886            /**
887             * Returns all the journal articles where uuid = &#63; and companyId = &#63;.
888             *
889             * @param uuid the uuid
890             * @param companyId the company ID
891             * @return the matching journal articles
892             * @throws SystemException if a system exception occurred
893             */
894            public List<JournalArticle> findByUuid_C(String uuid, long companyId)
895                    throws SystemException {
896                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
897                            QueryUtil.ALL_POS, null);
898            }
899    
900            /**
901             * Returns a range of all the journal articles where uuid = &#63; and companyId = &#63;.
902             *
903             * <p>
904             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
905             * </p>
906             *
907             * @param uuid the uuid
908             * @param companyId the company ID
909             * @param start the lower bound of the range of journal articles
910             * @param end the upper bound of the range of journal articles (not inclusive)
911             * @return the range of matching journal articles
912             * @throws SystemException if a system exception occurred
913             */
914            public List<JournalArticle> findByUuid_C(String uuid, long companyId,
915                    int start, int end) throws SystemException {
916                    return findByUuid_C(uuid, companyId, start, end, null);
917            }
918    
919            /**
920             * Returns an ordered range of all the journal articles where uuid = &#63; and companyId = &#63;.
921             *
922             * <p>
923             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
924             * </p>
925             *
926             * @param uuid the uuid
927             * @param companyId the company ID
928             * @param start the lower bound of the range of journal articles
929             * @param end the upper bound of the range of journal articles (not inclusive)
930             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
931             * @return the ordered range of matching journal articles
932             * @throws SystemException if a system exception occurred
933             */
934            public List<JournalArticle> findByUuid_C(String uuid, long companyId,
935                    int start, int end, OrderByComparator orderByComparator)
936                    throws SystemException {
937                    boolean pagination = true;
938                    FinderPath finderPath = null;
939                    Object[] finderArgs = null;
940    
941                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
942                                    (orderByComparator == null)) {
943                            pagination = false;
944                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
945                            finderArgs = new Object[] { uuid, companyId };
946                    }
947                    else {
948                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
949                            finderArgs = new Object[] {
950                                            uuid, companyId,
951                                            
952                                            start, end, orderByComparator
953                                    };
954                    }
955    
956                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
957                                    finderArgs, this);
958    
959                    if ((list != null) && !list.isEmpty()) {
960                            for (JournalArticle journalArticle : list) {
961                                    if (!Validator.equals(uuid, journalArticle.getUuid()) ||
962                                                    (companyId != journalArticle.getCompanyId())) {
963                                            list = null;
964    
965                                            break;
966                                    }
967                            }
968                    }
969    
970                    if (list == null) {
971                            StringBundler query = null;
972    
973                            if (orderByComparator != null) {
974                                    query = new StringBundler(4 +
975                                                    (orderByComparator.getOrderByFields().length * 3));
976                            }
977                            else {
978                                    query = new StringBundler(4);
979                            }
980    
981                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
982    
983                            if (uuid == null) {
984                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
985                            }
986                            else {
987                                    if (uuid.equals(StringPool.BLANK)) {
988                                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
989                                    }
990                                    else {
991                                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
992                                    }
993                            }
994    
995                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
996    
997                            if (orderByComparator != null) {
998                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
999                                            orderByComparator);
1000                            }
1001                            else
1002                             if (pagination) {
1003                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1004                            }
1005    
1006                            String sql = query.toString();
1007    
1008                            Session session = null;
1009    
1010                            try {
1011                                    session = openSession();
1012    
1013                                    Query q = session.createQuery(sql);
1014    
1015                                    QueryPos qPos = QueryPos.getInstance(q);
1016    
1017                                    if (uuid != null) {
1018                                            qPos.add(uuid);
1019                                    }
1020    
1021                                    qPos.add(companyId);
1022    
1023                                    if (!pagination) {
1024                                            list = (List<JournalArticle>)QueryUtil.list(q,
1025                                                            getDialect(), start, end, false);
1026    
1027                                            Collections.sort(list);
1028    
1029                                            list = new UnmodifiableList<JournalArticle>(list);
1030                                    }
1031                                    else {
1032                                            list = (List<JournalArticle>)QueryUtil.list(q,
1033                                                            getDialect(), start, end);
1034                                    }
1035    
1036                                    cacheResult(list);
1037    
1038                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1039                            }
1040                            catch (Exception e) {
1041                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1042    
1043                                    throw processException(e);
1044                            }
1045                            finally {
1046                                    closeSession(session);
1047                            }
1048                    }
1049    
1050                    return list;
1051            }
1052    
1053            /**
1054             * Returns the first journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1055             *
1056             * @param uuid the uuid
1057             * @param companyId the company ID
1058             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1059             * @return the first matching journal article
1060             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1061             * @throws SystemException if a system exception occurred
1062             */
1063            public JournalArticle findByUuid_C_First(String uuid, long companyId,
1064                    OrderByComparator orderByComparator)
1065                    throws NoSuchArticleException, SystemException {
1066                    JournalArticle journalArticle = fetchByUuid_C_First(uuid, companyId,
1067                                    orderByComparator);
1068    
1069                    if (journalArticle != null) {
1070                            return journalArticle;
1071                    }
1072    
1073                    StringBundler msg = new StringBundler(6);
1074    
1075                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1076    
1077                    msg.append("uuid=");
1078                    msg.append(uuid);
1079    
1080                    msg.append(", companyId=");
1081                    msg.append(companyId);
1082    
1083                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1084    
1085                    throw new NoSuchArticleException(msg.toString());
1086            }
1087    
1088            /**
1089             * Returns the first journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1090             *
1091             * @param uuid the uuid
1092             * @param companyId the company ID
1093             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1094             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
1095             * @throws SystemException if a system exception occurred
1096             */
1097            public JournalArticle fetchByUuid_C_First(String uuid, long companyId,
1098                    OrderByComparator orderByComparator) throws SystemException {
1099                    List<JournalArticle> list = findByUuid_C(uuid, companyId, 0, 1,
1100                                    orderByComparator);
1101    
1102                    if (!list.isEmpty()) {
1103                            return list.get(0);
1104                    }
1105    
1106                    return null;
1107            }
1108    
1109            /**
1110             * Returns the last journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1111             *
1112             * @param uuid the uuid
1113             * @param companyId the company ID
1114             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1115             * @return the last matching journal article
1116             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1117             * @throws SystemException if a system exception occurred
1118             */
1119            public JournalArticle findByUuid_C_Last(String uuid, long companyId,
1120                    OrderByComparator orderByComparator)
1121                    throws NoSuchArticleException, SystemException {
1122                    JournalArticle journalArticle = fetchByUuid_C_Last(uuid, companyId,
1123                                    orderByComparator);
1124    
1125                    if (journalArticle != null) {
1126                            return journalArticle;
1127                    }
1128    
1129                    StringBundler msg = new StringBundler(6);
1130    
1131                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1132    
1133                    msg.append("uuid=");
1134                    msg.append(uuid);
1135    
1136                    msg.append(", companyId=");
1137                    msg.append(companyId);
1138    
1139                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1140    
1141                    throw new NoSuchArticleException(msg.toString());
1142            }
1143    
1144            /**
1145             * Returns the last journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1146             *
1147             * @param uuid the uuid
1148             * @param companyId the company ID
1149             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1150             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
1151             * @throws SystemException if a system exception occurred
1152             */
1153            public JournalArticle fetchByUuid_C_Last(String uuid, long companyId,
1154                    OrderByComparator orderByComparator) throws SystemException {
1155                    int count = countByUuid_C(uuid, companyId);
1156    
1157                    List<JournalArticle> list = findByUuid_C(uuid, companyId, count - 1,
1158                                    count, orderByComparator);
1159    
1160                    if (!list.isEmpty()) {
1161                            return list.get(0);
1162                    }
1163    
1164                    return null;
1165            }
1166    
1167            /**
1168             * Returns the journal articles before and after the current journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1169             *
1170             * @param id the primary key of the current journal article
1171             * @param uuid the uuid
1172             * @param companyId the company ID
1173             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1174             * @return the previous, current, and next journal article
1175             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
1176             * @throws SystemException if a system exception occurred
1177             */
1178            public JournalArticle[] findByUuid_C_PrevAndNext(long id, String uuid,
1179                    long companyId, OrderByComparator orderByComparator)
1180                    throws NoSuchArticleException, SystemException {
1181                    JournalArticle journalArticle = findByPrimaryKey(id);
1182    
1183                    Session session = null;
1184    
1185                    try {
1186                            session = openSession();
1187    
1188                            JournalArticle[] array = new JournalArticleImpl[3];
1189    
1190                            array[0] = getByUuid_C_PrevAndNext(session, journalArticle, uuid,
1191                                            companyId, orderByComparator, true);
1192    
1193                            array[1] = journalArticle;
1194    
1195                            array[2] = getByUuid_C_PrevAndNext(session, journalArticle, uuid,
1196                                            companyId, orderByComparator, false);
1197    
1198                            return array;
1199                    }
1200                    catch (Exception e) {
1201                            throw processException(e);
1202                    }
1203                    finally {
1204                            closeSession(session);
1205                    }
1206            }
1207    
1208            protected JournalArticle getByUuid_C_PrevAndNext(Session session,
1209                    JournalArticle journalArticle, String uuid, long companyId,
1210                    OrderByComparator orderByComparator, boolean previous) {
1211                    StringBundler query = null;
1212    
1213                    if (orderByComparator != null) {
1214                            query = new StringBundler(6 +
1215                                            (orderByComparator.getOrderByFields().length * 6));
1216                    }
1217                    else {
1218                            query = new StringBundler(3);
1219                    }
1220    
1221                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1222    
1223                    if (uuid == null) {
1224                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1225                    }
1226                    else {
1227                            if (uuid.equals(StringPool.BLANK)) {
1228                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1229                            }
1230                            else {
1231                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1232                            }
1233                    }
1234    
1235                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1236    
1237                    if (orderByComparator != null) {
1238                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1239    
1240                            if (orderByConditionFields.length > 0) {
1241                                    query.append(WHERE_AND);
1242                            }
1243    
1244                            for (int i = 0; i < orderByConditionFields.length; i++) {
1245                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1246                                    query.append(orderByConditionFields[i]);
1247    
1248                                    if ((i + 1) < orderByConditionFields.length) {
1249                                            if (orderByComparator.isAscending() ^ previous) {
1250                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1251                                            }
1252                                            else {
1253                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1254                                            }
1255                                    }
1256                                    else {
1257                                            if (orderByComparator.isAscending() ^ previous) {
1258                                                    query.append(WHERE_GREATER_THAN);
1259                                            }
1260                                            else {
1261                                                    query.append(WHERE_LESSER_THAN);
1262                                            }
1263                                    }
1264                            }
1265    
1266                            query.append(ORDER_BY_CLAUSE);
1267    
1268                            String[] orderByFields = orderByComparator.getOrderByFields();
1269    
1270                            for (int i = 0; i < orderByFields.length; i++) {
1271                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1272                                    query.append(orderByFields[i]);
1273    
1274                                    if ((i + 1) < orderByFields.length) {
1275                                            if (orderByComparator.isAscending() ^ previous) {
1276                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1277                                            }
1278                                            else {
1279                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1280                                            }
1281                                    }
1282                                    else {
1283                                            if (orderByComparator.isAscending() ^ previous) {
1284                                                    query.append(ORDER_BY_ASC);
1285                                            }
1286                                            else {
1287                                                    query.append(ORDER_BY_DESC);
1288                                            }
1289                                    }
1290                            }
1291                    }
1292                    else {
1293                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1294                    }
1295    
1296                    String sql = query.toString();
1297    
1298                    Query q = session.createQuery(sql);
1299    
1300                    q.setFirstResult(0);
1301                    q.setMaxResults(2);
1302    
1303                    QueryPos qPos = QueryPos.getInstance(q);
1304    
1305                    if (uuid != null) {
1306                            qPos.add(uuid);
1307                    }
1308    
1309                    qPos.add(companyId);
1310    
1311                    if (orderByComparator != null) {
1312                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
1313    
1314                            for (Object value : values) {
1315                                    qPos.add(value);
1316                            }
1317                    }
1318    
1319                    List<JournalArticle> list = q.list();
1320    
1321                    if (list.size() == 2) {
1322                            return list.get(1);
1323                    }
1324                    else {
1325                            return null;
1326                    }
1327            }
1328    
1329            /**
1330             * Removes all the journal articles where uuid = &#63; and companyId = &#63; from the database.
1331             *
1332             * @param uuid the uuid
1333             * @param companyId the company ID
1334             * @throws SystemException if a system exception occurred
1335             */
1336            public void removeByUuid_C(String uuid, long companyId)
1337                    throws SystemException {
1338                    for (JournalArticle journalArticle : findByUuid_C(uuid, companyId,
1339                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1340                            remove(journalArticle);
1341                    }
1342            }
1343    
1344            /**
1345             * Returns the number of journal articles where uuid = &#63; and companyId = &#63;.
1346             *
1347             * @param uuid the uuid
1348             * @param companyId the company ID
1349             * @return the number of matching journal articles
1350             * @throws SystemException if a system exception occurred
1351             */
1352            public int countByUuid_C(String uuid, long companyId)
1353                    throws SystemException {
1354                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1355    
1356                    Object[] finderArgs = new Object[] { uuid, companyId };
1357    
1358                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1359                                    this);
1360    
1361                    if (count == null) {
1362                            StringBundler query = new StringBundler(3);
1363    
1364                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
1365    
1366                            if (uuid == null) {
1367                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1368                            }
1369                            else {
1370                                    if (uuid.equals(StringPool.BLANK)) {
1371                                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1372                                    }
1373                                    else {
1374                                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1375                                    }
1376                            }
1377    
1378                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1379    
1380                            String sql = query.toString();
1381    
1382                            Session session = null;
1383    
1384                            try {
1385                                    session = openSession();
1386    
1387                                    Query q = session.createQuery(sql);
1388    
1389                                    QueryPos qPos = QueryPos.getInstance(q);
1390    
1391                                    if (uuid != null) {
1392                                            qPos.add(uuid);
1393                                    }
1394    
1395                                    qPos.add(companyId);
1396    
1397                                    count = (Long)q.uniqueResult();
1398    
1399                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1400                            }
1401                            catch (Exception e) {
1402                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1403    
1404                                    throw processException(e);
1405                            }
1406                            finally {
1407                                    closeSession(session);
1408                            }
1409                    }
1410    
1411                    return count.intValue();
1412            }
1413    
1414            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "journalArticle.uuid IS NULL AND ";
1415            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "journalArticle.uuid = ? AND ";
1416            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = ?) AND ";
1417            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "journalArticle.companyId = ?";
1418            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEPRIMKEY =
1419                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1420                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
1421                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1422                            "findByResourcePrimKey",
1423                            new String[] {
1424                                    Long.class.getName(),
1425                                    
1426                            Integer.class.getName(), Integer.class.getName(),
1427                                    OrderByComparator.class.getName()
1428                            });
1429            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY =
1430                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1431                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
1432                            JournalArticleImpl.class,
1433                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByResourcePrimKey",
1434                            new String[] { Long.class.getName() },
1435                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
1436                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
1437                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
1438            public static final FinderPath FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1439                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
1440                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
1441                            "countByResourcePrimKey", new String[] { Long.class.getName() });
1442    
1443            /**
1444             * Returns all the journal articles where resourcePrimKey = &#63;.
1445             *
1446             * @param resourcePrimKey the resource prim key
1447             * @return the matching journal articles
1448             * @throws SystemException if a system exception occurred
1449             */
1450            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey)
1451                    throws SystemException {
1452                    return findByResourcePrimKey(resourcePrimKey, QueryUtil.ALL_POS,
1453                            QueryUtil.ALL_POS, null);
1454            }
1455    
1456            /**
1457             * Returns a range of all the journal articles where resourcePrimKey = &#63;.
1458             *
1459             * <p>
1460             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1461             * </p>
1462             *
1463             * @param resourcePrimKey the resource prim key
1464             * @param start the lower bound of the range of journal articles
1465             * @param end the upper bound of the range of journal articles (not inclusive)
1466             * @return the range of matching journal articles
1467             * @throws SystemException if a system exception occurred
1468             */
1469            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey,
1470                    int start, int end) throws SystemException {
1471                    return findByResourcePrimKey(resourcePrimKey, start, end, null);
1472            }
1473    
1474            /**
1475             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63;.
1476             *
1477             * <p>
1478             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1479             * </p>
1480             *
1481             * @param resourcePrimKey the resource prim key
1482             * @param start the lower bound of the range of journal articles
1483             * @param end the upper bound of the range of journal articles (not inclusive)
1484             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1485             * @return the ordered range of matching journal articles
1486             * @throws SystemException if a system exception occurred
1487             */
1488            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey,
1489                    int start, int end, OrderByComparator orderByComparator)
1490                    throws SystemException {
1491                    boolean pagination = true;
1492                    FinderPath finderPath = null;
1493                    Object[] finderArgs = null;
1494    
1495                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1496                                    (orderByComparator == null)) {
1497                            pagination = false;
1498                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY;
1499                            finderArgs = new Object[] { resourcePrimKey };
1500                    }
1501                    else {
1502                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEPRIMKEY;
1503                            finderArgs = new Object[] {
1504                                            resourcePrimKey,
1505                                            
1506                                            start, end, orderByComparator
1507                                    };
1508                    }
1509    
1510                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
1511                                    finderArgs, this);
1512    
1513                    if ((list != null) && !list.isEmpty()) {
1514                            for (JournalArticle journalArticle : list) {
1515                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey())) {
1516                                            list = null;
1517    
1518                                            break;
1519                                    }
1520                            }
1521                    }
1522    
1523                    if (list == null) {
1524                            StringBundler query = null;
1525    
1526                            if (orderByComparator != null) {
1527                                    query = new StringBundler(3 +
1528                                                    (orderByComparator.getOrderByFields().length * 3));
1529                            }
1530                            else {
1531                                    query = new StringBundler(3);
1532                            }
1533    
1534                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1535    
1536                            query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
1537    
1538                            if (orderByComparator != null) {
1539                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1540                                            orderByComparator);
1541                            }
1542                            else
1543                             if (pagination) {
1544                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1545                            }
1546    
1547                            String sql = query.toString();
1548    
1549                            Session session = null;
1550    
1551                            try {
1552                                    session = openSession();
1553    
1554                                    Query q = session.createQuery(sql);
1555    
1556                                    QueryPos qPos = QueryPos.getInstance(q);
1557    
1558                                    qPos.add(resourcePrimKey);
1559    
1560                                    if (!pagination) {
1561                                            list = (List<JournalArticle>)QueryUtil.list(q,
1562                                                            getDialect(), start, end, false);
1563    
1564                                            Collections.sort(list);
1565    
1566                                            list = new UnmodifiableList<JournalArticle>(list);
1567                                    }
1568                                    else {
1569                                            list = (List<JournalArticle>)QueryUtil.list(q,
1570                                                            getDialect(), start, end);
1571                                    }
1572    
1573                                    cacheResult(list);
1574    
1575                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1576                            }
1577                            catch (Exception e) {
1578                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1579    
1580                                    throw processException(e);
1581                            }
1582                            finally {
1583                                    closeSession(session);
1584                            }
1585                    }
1586    
1587                    return list;
1588            }
1589    
1590            /**
1591             * Returns the first journal article in the ordered set where resourcePrimKey = &#63;.
1592             *
1593             * @param resourcePrimKey the resource prim key
1594             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1595             * @return the first matching journal article
1596             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1597             * @throws SystemException if a system exception occurred
1598             */
1599            public JournalArticle findByResourcePrimKey_First(long resourcePrimKey,
1600                    OrderByComparator orderByComparator)
1601                    throws NoSuchArticleException, SystemException {
1602                    JournalArticle journalArticle = fetchByResourcePrimKey_First(resourcePrimKey,
1603                                    orderByComparator);
1604    
1605                    if (journalArticle != null) {
1606                            return journalArticle;
1607                    }
1608    
1609                    StringBundler msg = new StringBundler(4);
1610    
1611                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1612    
1613                    msg.append("resourcePrimKey=");
1614                    msg.append(resourcePrimKey);
1615    
1616                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1617    
1618                    throw new NoSuchArticleException(msg.toString());
1619            }
1620    
1621            /**
1622             * Returns the first journal article in the ordered set where resourcePrimKey = &#63;.
1623             *
1624             * @param resourcePrimKey the resource prim key
1625             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1626             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
1627             * @throws SystemException if a system exception occurred
1628             */
1629            public JournalArticle fetchByResourcePrimKey_First(long resourcePrimKey,
1630                    OrderByComparator orderByComparator) throws SystemException {
1631                    List<JournalArticle> list = findByResourcePrimKey(resourcePrimKey, 0,
1632                                    1, orderByComparator);
1633    
1634                    if (!list.isEmpty()) {
1635                            return list.get(0);
1636                    }
1637    
1638                    return null;
1639            }
1640    
1641            /**
1642             * Returns the last journal article in the ordered set where resourcePrimKey = &#63;.
1643             *
1644             * @param resourcePrimKey the resource prim key
1645             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1646             * @return the last matching journal article
1647             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1648             * @throws SystemException if a system exception occurred
1649             */
1650            public JournalArticle findByResourcePrimKey_Last(long resourcePrimKey,
1651                    OrderByComparator orderByComparator)
1652                    throws NoSuchArticleException, SystemException {
1653                    JournalArticle journalArticle = fetchByResourcePrimKey_Last(resourcePrimKey,
1654                                    orderByComparator);
1655    
1656                    if (journalArticle != null) {
1657                            return journalArticle;
1658                    }
1659    
1660                    StringBundler msg = new StringBundler(4);
1661    
1662                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1663    
1664                    msg.append("resourcePrimKey=");
1665                    msg.append(resourcePrimKey);
1666    
1667                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1668    
1669                    throw new NoSuchArticleException(msg.toString());
1670            }
1671    
1672            /**
1673             * Returns the last journal article in the ordered set where resourcePrimKey = &#63;.
1674             *
1675             * @param resourcePrimKey the resource prim key
1676             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1677             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
1678             * @throws SystemException if a system exception occurred
1679             */
1680            public JournalArticle fetchByResourcePrimKey_Last(long resourcePrimKey,
1681                    OrderByComparator orderByComparator) throws SystemException {
1682                    int count = countByResourcePrimKey(resourcePrimKey);
1683    
1684                    List<JournalArticle> list = findByResourcePrimKey(resourcePrimKey,
1685                                    count - 1, count, orderByComparator);
1686    
1687                    if (!list.isEmpty()) {
1688                            return list.get(0);
1689                    }
1690    
1691                    return null;
1692            }
1693    
1694            /**
1695             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63;.
1696             *
1697             * @param id the primary key of the current journal article
1698             * @param resourcePrimKey the resource prim key
1699             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1700             * @return the previous, current, and next journal article
1701             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
1702             * @throws SystemException if a system exception occurred
1703             */
1704            public JournalArticle[] findByResourcePrimKey_PrevAndNext(long id,
1705                    long resourcePrimKey, OrderByComparator orderByComparator)
1706                    throws NoSuchArticleException, SystemException {
1707                    JournalArticle journalArticle = findByPrimaryKey(id);
1708    
1709                    Session session = null;
1710    
1711                    try {
1712                            session = openSession();
1713    
1714                            JournalArticle[] array = new JournalArticleImpl[3];
1715    
1716                            array[0] = getByResourcePrimKey_PrevAndNext(session,
1717                                            journalArticle, resourcePrimKey, orderByComparator, true);
1718    
1719                            array[1] = journalArticle;
1720    
1721                            array[2] = getByResourcePrimKey_PrevAndNext(session,
1722                                            journalArticle, resourcePrimKey, orderByComparator, false);
1723    
1724                            return array;
1725                    }
1726                    catch (Exception e) {
1727                            throw processException(e);
1728                    }
1729                    finally {
1730                            closeSession(session);
1731                    }
1732            }
1733    
1734            protected JournalArticle getByResourcePrimKey_PrevAndNext(Session session,
1735                    JournalArticle journalArticle, long resourcePrimKey,
1736                    OrderByComparator orderByComparator, boolean previous) {
1737                    StringBundler query = null;
1738    
1739                    if (orderByComparator != null) {
1740                            query = new StringBundler(6 +
1741                                            (orderByComparator.getOrderByFields().length * 6));
1742                    }
1743                    else {
1744                            query = new StringBundler(3);
1745                    }
1746    
1747                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1748    
1749                    query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
1750    
1751                    if (orderByComparator != null) {
1752                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1753    
1754                            if (orderByConditionFields.length > 0) {
1755                                    query.append(WHERE_AND);
1756                            }
1757    
1758                            for (int i = 0; i < orderByConditionFields.length; i++) {
1759                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1760                                    query.append(orderByConditionFields[i]);
1761    
1762                                    if ((i + 1) < orderByConditionFields.length) {
1763                                            if (orderByComparator.isAscending() ^ previous) {
1764                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1765                                            }
1766                                            else {
1767                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1768                                            }
1769                                    }
1770                                    else {
1771                                            if (orderByComparator.isAscending() ^ previous) {
1772                                                    query.append(WHERE_GREATER_THAN);
1773                                            }
1774                                            else {
1775                                                    query.append(WHERE_LESSER_THAN);
1776                                            }
1777                                    }
1778                            }
1779    
1780                            query.append(ORDER_BY_CLAUSE);
1781    
1782                            String[] orderByFields = orderByComparator.getOrderByFields();
1783    
1784                            for (int i = 0; i < orderByFields.length; i++) {
1785                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1786                                    query.append(orderByFields[i]);
1787    
1788                                    if ((i + 1) < orderByFields.length) {
1789                                            if (orderByComparator.isAscending() ^ previous) {
1790                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1791                                            }
1792                                            else {
1793                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1794                                            }
1795                                    }
1796                                    else {
1797                                            if (orderByComparator.isAscending() ^ previous) {
1798                                                    query.append(ORDER_BY_ASC);
1799                                            }
1800                                            else {
1801                                                    query.append(ORDER_BY_DESC);
1802                                            }
1803                                    }
1804                            }
1805                    }
1806                    else {
1807                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1808                    }
1809    
1810                    String sql = query.toString();
1811    
1812                    Query q = session.createQuery(sql);
1813    
1814                    q.setFirstResult(0);
1815                    q.setMaxResults(2);
1816    
1817                    QueryPos qPos = QueryPos.getInstance(q);
1818    
1819                    qPos.add(resourcePrimKey);
1820    
1821                    if (orderByComparator != null) {
1822                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
1823    
1824                            for (Object value : values) {
1825                                    qPos.add(value);
1826                            }
1827                    }
1828    
1829                    List<JournalArticle> list = q.list();
1830    
1831                    if (list.size() == 2) {
1832                            return list.get(1);
1833                    }
1834                    else {
1835                            return null;
1836                    }
1837            }
1838    
1839            /**
1840             * Removes all the journal articles where resourcePrimKey = &#63; from the database.
1841             *
1842             * @param resourcePrimKey the resource prim key
1843             * @throws SystemException if a system exception occurred
1844             */
1845            public void removeByResourcePrimKey(long resourcePrimKey)
1846                    throws SystemException {
1847                    for (JournalArticle journalArticle : findByResourcePrimKey(
1848                                    resourcePrimKey, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1849                            remove(journalArticle);
1850                    }
1851            }
1852    
1853            /**
1854             * Returns the number of journal articles where resourcePrimKey = &#63;.
1855             *
1856             * @param resourcePrimKey the resource prim key
1857             * @return the number of matching journal articles
1858             * @throws SystemException if a system exception occurred
1859             */
1860            public int countByResourcePrimKey(long resourcePrimKey)
1861                    throws SystemException {
1862                    FinderPath finderPath = FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY;
1863    
1864                    Object[] finderArgs = new Object[] { resourcePrimKey };
1865    
1866                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1867                                    this);
1868    
1869                    if (count == null) {
1870                            StringBundler query = new StringBundler(2);
1871    
1872                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
1873    
1874                            query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
1875    
1876                            String sql = query.toString();
1877    
1878                            Session session = null;
1879    
1880                            try {
1881                                    session = openSession();
1882    
1883                                    Query q = session.createQuery(sql);
1884    
1885                                    QueryPos qPos = QueryPos.getInstance(q);
1886    
1887                                    qPos.add(resourcePrimKey);
1888    
1889                                    count = (Long)q.uniqueResult();
1890    
1891                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1892                            }
1893                            catch (Exception e) {
1894                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1895    
1896                                    throw processException(e);
1897                            }
1898                            finally {
1899                                    closeSession(session);
1900                            }
1901                    }
1902    
1903                    return count.intValue();
1904            }
1905    
1906            private static final String _FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2 =
1907                    "journalArticle.resourcePrimKey = ?";
1908            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1909                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
1910                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1911                            "findByGroupId",
1912                            new String[] {
1913                                    Long.class.getName(),
1914                                    
1915                            Integer.class.getName(), Integer.class.getName(),
1916                                    OrderByComparator.class.getName()
1917                            });
1918            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1919                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1920                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
1921                            JournalArticleImpl.class,
1922                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1923                            new String[] { Long.class.getName() },
1924                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
1925                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
1926                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
1927            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1928                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
1929                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1930                            new String[] { Long.class.getName() });
1931    
1932            /**
1933             * Returns all the journal articles where groupId = &#63;.
1934             *
1935             * @param groupId the group ID
1936             * @return the matching journal articles
1937             * @throws SystemException if a system exception occurred
1938             */
1939            public List<JournalArticle> findByGroupId(long groupId)
1940                    throws SystemException {
1941                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1942            }
1943    
1944            /**
1945             * Returns a range of all the journal articles where groupId = &#63;.
1946             *
1947             * <p>
1948             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1949             * </p>
1950             *
1951             * @param groupId the group ID
1952             * @param start the lower bound of the range of journal articles
1953             * @param end the upper bound of the range of journal articles (not inclusive)
1954             * @return the range of matching journal articles
1955             * @throws SystemException if a system exception occurred
1956             */
1957            public List<JournalArticle> findByGroupId(long groupId, int start, int end)
1958                    throws SystemException {
1959                    return findByGroupId(groupId, start, end, null);
1960            }
1961    
1962            /**
1963             * Returns an ordered range of all the journal articles where groupId = &#63;.
1964             *
1965             * <p>
1966             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1967             * </p>
1968             *
1969             * @param groupId the group ID
1970             * @param start the lower bound of the range of journal articles
1971             * @param end the upper bound of the range of journal articles (not inclusive)
1972             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1973             * @return the ordered range of matching journal articles
1974             * @throws SystemException if a system exception occurred
1975             */
1976            public List<JournalArticle> findByGroupId(long groupId, int start, int end,
1977                    OrderByComparator orderByComparator) throws SystemException {
1978                    boolean pagination = true;
1979                    FinderPath finderPath = null;
1980                    Object[] finderArgs = null;
1981    
1982                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1983                                    (orderByComparator == null)) {
1984                            pagination = false;
1985                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1986                            finderArgs = new Object[] { groupId };
1987                    }
1988                    else {
1989                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1990                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1991                    }
1992    
1993                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
1994                                    finderArgs, this);
1995    
1996                    if ((list != null) && !list.isEmpty()) {
1997                            for (JournalArticle journalArticle : list) {
1998                                    if ((groupId != journalArticle.getGroupId())) {
1999                                            list = null;
2000    
2001                                            break;
2002                                    }
2003                            }
2004                    }
2005    
2006                    if (list == null) {
2007                            StringBundler query = null;
2008    
2009                            if (orderByComparator != null) {
2010                                    query = new StringBundler(3 +
2011                                                    (orderByComparator.getOrderByFields().length * 3));
2012                            }
2013                            else {
2014                                    query = new StringBundler(3);
2015                            }
2016    
2017                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2018    
2019                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2020    
2021                            if (orderByComparator != null) {
2022                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2023                                            orderByComparator);
2024                            }
2025                            else
2026                             if (pagination) {
2027                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2028                            }
2029    
2030                            String sql = query.toString();
2031    
2032                            Session session = null;
2033    
2034                            try {
2035                                    session = openSession();
2036    
2037                                    Query q = session.createQuery(sql);
2038    
2039                                    QueryPos qPos = QueryPos.getInstance(q);
2040    
2041                                    qPos.add(groupId);
2042    
2043                                    if (!pagination) {
2044                                            list = (List<JournalArticle>)QueryUtil.list(q,
2045                                                            getDialect(), start, end, false);
2046    
2047                                            Collections.sort(list);
2048    
2049                                            list = new UnmodifiableList<JournalArticle>(list);
2050                                    }
2051                                    else {
2052                                            list = (List<JournalArticle>)QueryUtil.list(q,
2053                                                            getDialect(), start, end);
2054                                    }
2055    
2056                                    cacheResult(list);
2057    
2058                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2059                            }
2060                            catch (Exception e) {
2061                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2062    
2063                                    throw processException(e);
2064                            }
2065                            finally {
2066                                    closeSession(session);
2067                            }
2068                    }
2069    
2070                    return list;
2071            }
2072    
2073            /**
2074             * Returns the first journal article in the ordered set where groupId = &#63;.
2075             *
2076             * @param groupId the group ID
2077             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2078             * @return the first matching journal article
2079             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2080             * @throws SystemException if a system exception occurred
2081             */
2082            public JournalArticle findByGroupId_First(long groupId,
2083                    OrderByComparator orderByComparator)
2084                    throws NoSuchArticleException, SystemException {
2085                    JournalArticle journalArticle = fetchByGroupId_First(groupId,
2086                                    orderByComparator);
2087    
2088                    if (journalArticle != null) {
2089                            return journalArticle;
2090                    }
2091    
2092                    StringBundler msg = new StringBundler(4);
2093    
2094                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2095    
2096                    msg.append("groupId=");
2097                    msg.append(groupId);
2098    
2099                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2100    
2101                    throw new NoSuchArticleException(msg.toString());
2102            }
2103    
2104            /**
2105             * Returns the first journal article in the ordered set where groupId = &#63;.
2106             *
2107             * @param groupId the group ID
2108             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2109             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
2110             * @throws SystemException if a system exception occurred
2111             */
2112            public JournalArticle fetchByGroupId_First(long groupId,
2113                    OrderByComparator orderByComparator) throws SystemException {
2114                    List<JournalArticle> list = findByGroupId(groupId, 0, 1,
2115                                    orderByComparator);
2116    
2117                    if (!list.isEmpty()) {
2118                            return list.get(0);
2119                    }
2120    
2121                    return null;
2122            }
2123    
2124            /**
2125             * Returns the last journal article in the ordered set where groupId = &#63;.
2126             *
2127             * @param groupId the group ID
2128             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2129             * @return the last matching journal article
2130             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2131             * @throws SystemException if a system exception occurred
2132             */
2133            public JournalArticle findByGroupId_Last(long groupId,
2134                    OrderByComparator orderByComparator)
2135                    throws NoSuchArticleException, SystemException {
2136                    JournalArticle journalArticle = fetchByGroupId_Last(groupId,
2137                                    orderByComparator);
2138    
2139                    if (journalArticle != null) {
2140                            return journalArticle;
2141                    }
2142    
2143                    StringBundler msg = new StringBundler(4);
2144    
2145                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2146    
2147                    msg.append("groupId=");
2148                    msg.append(groupId);
2149    
2150                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2151    
2152                    throw new NoSuchArticleException(msg.toString());
2153            }
2154    
2155            /**
2156             * Returns the last journal article in the ordered set where groupId = &#63;.
2157             *
2158             * @param groupId the group ID
2159             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2160             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
2161             * @throws SystemException if a system exception occurred
2162             */
2163            public JournalArticle fetchByGroupId_Last(long groupId,
2164                    OrderByComparator orderByComparator) throws SystemException {
2165                    int count = countByGroupId(groupId);
2166    
2167                    List<JournalArticle> list = findByGroupId(groupId, count - 1, count,
2168                                    orderByComparator);
2169    
2170                    if (!list.isEmpty()) {
2171                            return list.get(0);
2172                    }
2173    
2174                    return null;
2175            }
2176    
2177            /**
2178             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63;.
2179             *
2180             * @param id the primary key of the current journal article
2181             * @param groupId the group ID
2182             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2183             * @return the previous, current, and next journal article
2184             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
2185             * @throws SystemException if a system exception occurred
2186             */
2187            public JournalArticle[] findByGroupId_PrevAndNext(long id, long groupId,
2188                    OrderByComparator orderByComparator)
2189                    throws NoSuchArticleException, SystemException {
2190                    JournalArticle journalArticle = findByPrimaryKey(id);
2191    
2192                    Session session = null;
2193    
2194                    try {
2195                            session = openSession();
2196    
2197                            JournalArticle[] array = new JournalArticleImpl[3];
2198    
2199                            array[0] = getByGroupId_PrevAndNext(session, journalArticle,
2200                                            groupId, orderByComparator, true);
2201    
2202                            array[1] = journalArticle;
2203    
2204                            array[2] = getByGroupId_PrevAndNext(session, journalArticle,
2205                                            groupId, orderByComparator, false);
2206    
2207                            return array;
2208                    }
2209                    catch (Exception e) {
2210                            throw processException(e);
2211                    }
2212                    finally {
2213                            closeSession(session);
2214                    }
2215            }
2216    
2217            protected JournalArticle getByGroupId_PrevAndNext(Session session,
2218                    JournalArticle journalArticle, long groupId,
2219                    OrderByComparator orderByComparator, boolean previous) {
2220                    StringBundler query = null;
2221    
2222                    if (orderByComparator != null) {
2223                            query = new StringBundler(6 +
2224                                            (orderByComparator.getOrderByFields().length * 6));
2225                    }
2226                    else {
2227                            query = new StringBundler(3);
2228                    }
2229    
2230                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2231    
2232                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2233    
2234                    if (orderByComparator != null) {
2235                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2236    
2237                            if (orderByConditionFields.length > 0) {
2238                                    query.append(WHERE_AND);
2239                            }
2240    
2241                            for (int i = 0; i < orderByConditionFields.length; i++) {
2242                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2243                                    query.append(orderByConditionFields[i]);
2244    
2245                                    if ((i + 1) < orderByConditionFields.length) {
2246                                            if (orderByComparator.isAscending() ^ previous) {
2247                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2248                                            }
2249                                            else {
2250                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2251                                            }
2252                                    }
2253                                    else {
2254                                            if (orderByComparator.isAscending() ^ previous) {
2255                                                    query.append(WHERE_GREATER_THAN);
2256                                            }
2257                                            else {
2258                                                    query.append(WHERE_LESSER_THAN);
2259                                            }
2260                                    }
2261                            }
2262    
2263                            query.append(ORDER_BY_CLAUSE);
2264    
2265                            String[] orderByFields = orderByComparator.getOrderByFields();
2266    
2267                            for (int i = 0; i < orderByFields.length; i++) {
2268                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2269                                    query.append(orderByFields[i]);
2270    
2271                                    if ((i + 1) < orderByFields.length) {
2272                                            if (orderByComparator.isAscending() ^ previous) {
2273                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2274                                            }
2275                                            else {
2276                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2277                                            }
2278                                    }
2279                                    else {
2280                                            if (orderByComparator.isAscending() ^ previous) {
2281                                                    query.append(ORDER_BY_ASC);
2282                                            }
2283                                            else {
2284                                                    query.append(ORDER_BY_DESC);
2285                                            }
2286                                    }
2287                            }
2288                    }
2289                    else {
2290                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2291                    }
2292    
2293                    String sql = query.toString();
2294    
2295                    Query q = session.createQuery(sql);
2296    
2297                    q.setFirstResult(0);
2298                    q.setMaxResults(2);
2299    
2300                    QueryPos qPos = QueryPos.getInstance(q);
2301    
2302                    qPos.add(groupId);
2303    
2304                    if (orderByComparator != null) {
2305                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
2306    
2307                            for (Object value : values) {
2308                                    qPos.add(value);
2309                            }
2310                    }
2311    
2312                    List<JournalArticle> list = q.list();
2313    
2314                    if (list.size() == 2) {
2315                            return list.get(1);
2316                    }
2317                    else {
2318                            return null;
2319                    }
2320            }
2321    
2322            /**
2323             * Returns all the journal articles that the user has permission to view where groupId = &#63;.
2324             *
2325             * @param groupId the group ID
2326             * @return the matching journal articles that the user has permission to view
2327             * @throws SystemException if a system exception occurred
2328             */
2329            public List<JournalArticle> filterFindByGroupId(long groupId)
2330                    throws SystemException {
2331                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
2332                            QueryUtil.ALL_POS, null);
2333            }
2334    
2335            /**
2336             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63;.
2337             *
2338             * <p>
2339             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2340             * </p>
2341             *
2342             * @param groupId the group ID
2343             * @param start the lower bound of the range of journal articles
2344             * @param end the upper bound of the range of journal articles (not inclusive)
2345             * @return the range of matching journal articles that the user has permission to view
2346             * @throws SystemException if a system exception occurred
2347             */
2348            public List<JournalArticle> filterFindByGroupId(long groupId, int start,
2349                    int end) throws SystemException {
2350                    return filterFindByGroupId(groupId, start, end, null);
2351            }
2352    
2353            /**
2354             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63;.
2355             *
2356             * <p>
2357             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2358             * </p>
2359             *
2360             * @param groupId the group ID
2361             * @param start the lower bound of the range of journal articles
2362             * @param end the upper bound of the range of journal articles (not inclusive)
2363             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2364             * @return the ordered range of matching journal articles that the user has permission to view
2365             * @throws SystemException if a system exception occurred
2366             */
2367            public List<JournalArticle> filterFindByGroupId(long groupId, int start,
2368                    int end, OrderByComparator orderByComparator) throws SystemException {
2369                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2370                            return findByGroupId(groupId, start, end, orderByComparator);
2371                    }
2372    
2373                    StringBundler query = null;
2374    
2375                    if (orderByComparator != null) {
2376                            query = new StringBundler(3 +
2377                                            (orderByComparator.getOrderByFields().length * 3));
2378                    }
2379                    else {
2380                            query = new StringBundler(3);
2381                    }
2382    
2383                    if (getDB().isSupportsInlineDistinct()) {
2384                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
2385                    }
2386                    else {
2387                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
2388                    }
2389    
2390                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2391    
2392                    if (!getDB().isSupportsInlineDistinct()) {
2393                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
2394                    }
2395    
2396                    if (orderByComparator != null) {
2397                            if (getDB().isSupportsInlineDistinct()) {
2398                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2399                                            orderByComparator);
2400                            }
2401                            else {
2402                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2403                                            orderByComparator);
2404                            }
2405                    }
2406                    else {
2407                            if (getDB().isSupportsInlineDistinct()) {
2408                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2409                            }
2410                            else {
2411                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
2412                            }
2413                    }
2414    
2415                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2416                                    JournalArticle.class.getName(),
2417                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2418    
2419                    Session session = null;
2420    
2421                    try {
2422                            session = openSession();
2423    
2424                            SQLQuery q = session.createSQLQuery(sql);
2425    
2426                            if (getDB().isSupportsInlineDistinct()) {
2427                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
2428                            }
2429                            else {
2430                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
2431                            }
2432    
2433                            QueryPos qPos = QueryPos.getInstance(q);
2434    
2435                            qPos.add(groupId);
2436    
2437                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
2438                                    end);
2439                    }
2440                    catch (Exception e) {
2441                            throw processException(e);
2442                    }
2443                    finally {
2444                            closeSession(session);
2445                    }
2446            }
2447    
2448            /**
2449             * 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;.
2450             *
2451             * @param id the primary key of the current journal article
2452             * @param groupId the group ID
2453             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2454             * @return the previous, current, and next journal article
2455             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
2456             * @throws SystemException if a system exception occurred
2457             */
2458            public JournalArticle[] filterFindByGroupId_PrevAndNext(long id,
2459                    long groupId, OrderByComparator orderByComparator)
2460                    throws NoSuchArticleException, SystemException {
2461                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2462                            return findByGroupId_PrevAndNext(id, groupId, orderByComparator);
2463                    }
2464    
2465                    JournalArticle journalArticle = findByPrimaryKey(id);
2466    
2467                    Session session = null;
2468    
2469                    try {
2470                            session = openSession();
2471    
2472                            JournalArticle[] array = new JournalArticleImpl[3];
2473    
2474                            array[0] = filterGetByGroupId_PrevAndNext(session, journalArticle,
2475                                            groupId, orderByComparator, true);
2476    
2477                            array[1] = journalArticle;
2478    
2479                            array[2] = filterGetByGroupId_PrevAndNext(session, journalArticle,
2480                                            groupId, orderByComparator, false);
2481    
2482                            return array;
2483                    }
2484                    catch (Exception e) {
2485                            throw processException(e);
2486                    }
2487                    finally {
2488                            closeSession(session);
2489                    }
2490            }
2491    
2492            protected JournalArticle filterGetByGroupId_PrevAndNext(Session session,
2493                    JournalArticle journalArticle, long groupId,
2494                    OrderByComparator orderByComparator, boolean previous) {
2495                    StringBundler query = null;
2496    
2497                    if (orderByComparator != null) {
2498                            query = new StringBundler(6 +
2499                                            (orderByComparator.getOrderByFields().length * 6));
2500                    }
2501                    else {
2502                            query = new StringBundler(3);
2503                    }
2504    
2505                    if (getDB().isSupportsInlineDistinct()) {
2506                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
2507                    }
2508                    else {
2509                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
2510                    }
2511    
2512                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2513    
2514                    if (!getDB().isSupportsInlineDistinct()) {
2515                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
2516                    }
2517    
2518                    if (orderByComparator != null) {
2519                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2520    
2521                            if (orderByConditionFields.length > 0) {
2522                                    query.append(WHERE_AND);
2523                            }
2524    
2525                            for (int i = 0; i < orderByConditionFields.length; i++) {
2526                                    if (getDB().isSupportsInlineDistinct()) {
2527                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2528                                    }
2529                                    else {
2530                                            query.append(_ORDER_BY_ENTITY_TABLE);
2531                                    }
2532    
2533                                    query.append(orderByConditionFields[i]);
2534    
2535                                    if ((i + 1) < orderByConditionFields.length) {
2536                                            if (orderByComparator.isAscending() ^ previous) {
2537                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2538                                            }
2539                                            else {
2540                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2541                                            }
2542                                    }
2543                                    else {
2544                                            if (orderByComparator.isAscending() ^ previous) {
2545                                                    query.append(WHERE_GREATER_THAN);
2546                                            }
2547                                            else {
2548                                                    query.append(WHERE_LESSER_THAN);
2549                                            }
2550                                    }
2551                            }
2552    
2553                            query.append(ORDER_BY_CLAUSE);
2554    
2555                            String[] orderByFields = orderByComparator.getOrderByFields();
2556    
2557                            for (int i = 0; i < orderByFields.length; i++) {
2558                                    if (getDB().isSupportsInlineDistinct()) {
2559                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2560                                    }
2561                                    else {
2562                                            query.append(_ORDER_BY_ENTITY_TABLE);
2563                                    }
2564    
2565                                    query.append(orderByFields[i]);
2566    
2567                                    if ((i + 1) < orderByFields.length) {
2568                                            if (orderByComparator.isAscending() ^ previous) {
2569                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2570                                            }
2571                                            else {
2572                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2573                                            }
2574                                    }
2575                                    else {
2576                                            if (orderByComparator.isAscending() ^ previous) {
2577                                                    query.append(ORDER_BY_ASC);
2578                                            }
2579                                            else {
2580                                                    query.append(ORDER_BY_DESC);
2581                                            }
2582                                    }
2583                            }
2584                    }
2585                    else {
2586                            if (getDB().isSupportsInlineDistinct()) {
2587                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2588                            }
2589                            else {
2590                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
2591                            }
2592                    }
2593    
2594                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2595                                    JournalArticle.class.getName(),
2596                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2597    
2598                    SQLQuery q = session.createSQLQuery(sql);
2599    
2600                    q.setFirstResult(0);
2601                    q.setMaxResults(2);
2602    
2603                    if (getDB().isSupportsInlineDistinct()) {
2604                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
2605                    }
2606                    else {
2607                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
2608                    }
2609    
2610                    QueryPos qPos = QueryPos.getInstance(q);
2611    
2612                    qPos.add(groupId);
2613    
2614                    if (orderByComparator != null) {
2615                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
2616    
2617                            for (Object value : values) {
2618                                    qPos.add(value);
2619                            }
2620                    }
2621    
2622                    List<JournalArticle> list = q.list();
2623    
2624                    if (list.size() == 2) {
2625                            return list.get(1);
2626                    }
2627                    else {
2628                            return null;
2629                    }
2630            }
2631    
2632            /**
2633             * Removes all the journal articles where groupId = &#63; from the database.
2634             *
2635             * @param groupId the group ID
2636             * @throws SystemException if a system exception occurred
2637             */
2638            public void removeByGroupId(long groupId) throws SystemException {
2639                    for (JournalArticle journalArticle : findByGroupId(groupId,
2640                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2641                            remove(journalArticle);
2642                    }
2643            }
2644    
2645            /**
2646             * Returns the number of journal articles where groupId = &#63;.
2647             *
2648             * @param groupId the group ID
2649             * @return the number of matching journal articles
2650             * @throws SystemException if a system exception occurred
2651             */
2652            public int countByGroupId(long groupId) throws SystemException {
2653                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2654    
2655                    Object[] finderArgs = new Object[] { groupId };
2656    
2657                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2658                                    this);
2659    
2660                    if (count == null) {
2661                            StringBundler query = new StringBundler(2);
2662    
2663                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
2664    
2665                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2666    
2667                            String sql = query.toString();
2668    
2669                            Session session = null;
2670    
2671                            try {
2672                                    session = openSession();
2673    
2674                                    Query q = session.createQuery(sql);
2675    
2676                                    QueryPos qPos = QueryPos.getInstance(q);
2677    
2678                                    qPos.add(groupId);
2679    
2680                                    count = (Long)q.uniqueResult();
2681    
2682                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2683                            }
2684                            catch (Exception e) {
2685                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2686    
2687                                    throw processException(e);
2688                            }
2689                            finally {
2690                                    closeSession(session);
2691                            }
2692                    }
2693    
2694                    return count.intValue();
2695            }
2696    
2697            /**
2698             * Returns the number of journal articles that the user has permission to view where groupId = &#63;.
2699             *
2700             * @param groupId the group ID
2701             * @return the number of matching journal articles that the user has permission to view
2702             * @throws SystemException if a system exception occurred
2703             */
2704            public int filterCountByGroupId(long groupId) throws SystemException {
2705                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2706                            return countByGroupId(groupId);
2707                    }
2708    
2709                    StringBundler query = new StringBundler(2);
2710    
2711                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
2712    
2713                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2714    
2715                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2716                                    JournalArticle.class.getName(),
2717                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2718    
2719                    Session session = null;
2720    
2721                    try {
2722                            session = openSession();
2723    
2724                            SQLQuery q = session.createSQLQuery(sql);
2725    
2726                            q.addScalar(COUNT_COLUMN_NAME,
2727                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2728    
2729                            QueryPos qPos = QueryPos.getInstance(q);
2730    
2731                            qPos.add(groupId);
2732    
2733                            Long count = (Long)q.uniqueResult();
2734    
2735                            return count.intValue();
2736                    }
2737                    catch (Exception e) {
2738                            throw processException(e);
2739                    }
2740                    finally {
2741                            closeSession(session);
2742                    }
2743            }
2744    
2745            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "journalArticle.groupId = ?";
2746            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2747                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
2748                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
2749                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2750                            "findByCompanyId",
2751                            new String[] {
2752                                    Long.class.getName(),
2753                                    
2754                            Integer.class.getName(), Integer.class.getName(),
2755                                    OrderByComparator.class.getName()
2756                            });
2757            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2758                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
2759                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
2760                            JournalArticleImpl.class,
2761                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2762                            new String[] { Long.class.getName() },
2763                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
2764                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
2765                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
2766            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
2767                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
2768                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2769                            new String[] { Long.class.getName() });
2770    
2771            /**
2772             * Returns all the journal articles where companyId = &#63;.
2773             *
2774             * @param companyId the company ID
2775             * @return the matching journal articles
2776             * @throws SystemException if a system exception occurred
2777             */
2778            public List<JournalArticle> findByCompanyId(long companyId)
2779                    throws SystemException {
2780                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2781                            null);
2782            }
2783    
2784            /**
2785             * Returns a range of all the journal articles where companyId = &#63;.
2786             *
2787             * <p>
2788             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2789             * </p>
2790             *
2791             * @param companyId the company ID
2792             * @param start the lower bound of the range of journal articles
2793             * @param end the upper bound of the range of journal articles (not inclusive)
2794             * @return the range of matching journal articles
2795             * @throws SystemException if a system exception occurred
2796             */
2797            public List<JournalArticle> findByCompanyId(long companyId, int start,
2798                    int end) throws SystemException {
2799                    return findByCompanyId(companyId, start, end, null);
2800            }
2801    
2802            /**
2803             * Returns an ordered range of all the journal articles where companyId = &#63;.
2804             *
2805             * <p>
2806             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2807             * </p>
2808             *
2809             * @param companyId the company ID
2810             * @param start the lower bound of the range of journal articles
2811             * @param end the upper bound of the range of journal articles (not inclusive)
2812             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2813             * @return the ordered range of matching journal articles
2814             * @throws SystemException if a system exception occurred
2815             */
2816            public List<JournalArticle> findByCompanyId(long companyId, int start,
2817                    int end, OrderByComparator orderByComparator) throws SystemException {
2818                    boolean pagination = true;
2819                    FinderPath finderPath = null;
2820                    Object[] finderArgs = null;
2821    
2822                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2823                                    (orderByComparator == null)) {
2824                            pagination = false;
2825                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2826                            finderArgs = new Object[] { companyId };
2827                    }
2828                    else {
2829                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2830                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2831                    }
2832    
2833                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
2834                                    finderArgs, this);
2835    
2836                    if ((list != null) && !list.isEmpty()) {
2837                            for (JournalArticle journalArticle : list) {
2838                                    if ((companyId != journalArticle.getCompanyId())) {
2839                                            list = null;
2840    
2841                                            break;
2842                                    }
2843                            }
2844                    }
2845    
2846                    if (list == null) {
2847                            StringBundler query = null;
2848    
2849                            if (orderByComparator != null) {
2850                                    query = new StringBundler(3 +
2851                                                    (orderByComparator.getOrderByFields().length * 3));
2852                            }
2853                            else {
2854                                    query = new StringBundler(3);
2855                            }
2856    
2857                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2858    
2859                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2860    
2861                            if (orderByComparator != null) {
2862                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2863                                            orderByComparator);
2864                            }
2865                            else
2866                             if (pagination) {
2867                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2868                            }
2869    
2870                            String sql = query.toString();
2871    
2872                            Session session = null;
2873    
2874                            try {
2875                                    session = openSession();
2876    
2877                                    Query q = session.createQuery(sql);
2878    
2879                                    QueryPos qPos = QueryPos.getInstance(q);
2880    
2881                                    qPos.add(companyId);
2882    
2883                                    if (!pagination) {
2884                                            list = (List<JournalArticle>)QueryUtil.list(q,
2885                                                            getDialect(), start, end, false);
2886    
2887                                            Collections.sort(list);
2888    
2889                                            list = new UnmodifiableList<JournalArticle>(list);
2890                                    }
2891                                    else {
2892                                            list = (List<JournalArticle>)QueryUtil.list(q,
2893                                                            getDialect(), start, end);
2894                                    }
2895    
2896                                    cacheResult(list);
2897    
2898                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2899                            }
2900                            catch (Exception e) {
2901                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2902    
2903                                    throw processException(e);
2904                            }
2905                            finally {
2906                                    closeSession(session);
2907                            }
2908                    }
2909    
2910                    return list;
2911            }
2912    
2913            /**
2914             * Returns the first journal article in the ordered set where companyId = &#63;.
2915             *
2916             * @param companyId the company ID
2917             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2918             * @return the first matching journal article
2919             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2920             * @throws SystemException if a system exception occurred
2921             */
2922            public JournalArticle findByCompanyId_First(long companyId,
2923                    OrderByComparator orderByComparator)
2924                    throws NoSuchArticleException, SystemException {
2925                    JournalArticle journalArticle = fetchByCompanyId_First(companyId,
2926                                    orderByComparator);
2927    
2928                    if (journalArticle != null) {
2929                            return journalArticle;
2930                    }
2931    
2932                    StringBundler msg = new StringBundler(4);
2933    
2934                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2935    
2936                    msg.append("companyId=");
2937                    msg.append(companyId);
2938    
2939                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2940    
2941                    throw new NoSuchArticleException(msg.toString());
2942            }
2943    
2944            /**
2945             * Returns the first journal article in the ordered set where companyId = &#63;.
2946             *
2947             * @param companyId the company ID
2948             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2949             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
2950             * @throws SystemException if a system exception occurred
2951             */
2952            public JournalArticle fetchByCompanyId_First(long companyId,
2953                    OrderByComparator orderByComparator) throws SystemException {
2954                    List<JournalArticle> list = findByCompanyId(companyId, 0, 1,
2955                                    orderByComparator);
2956    
2957                    if (!list.isEmpty()) {
2958                            return list.get(0);
2959                    }
2960    
2961                    return null;
2962            }
2963    
2964            /**
2965             * Returns the last journal article in the ordered set where companyId = &#63;.
2966             *
2967             * @param companyId the company ID
2968             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2969             * @return the last matching journal article
2970             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2971             * @throws SystemException if a system exception occurred
2972             */
2973            public JournalArticle findByCompanyId_Last(long companyId,
2974                    OrderByComparator orderByComparator)
2975                    throws NoSuchArticleException, SystemException {
2976                    JournalArticle journalArticle = fetchByCompanyId_Last(companyId,
2977                                    orderByComparator);
2978    
2979                    if (journalArticle != null) {
2980                            return journalArticle;
2981                    }
2982    
2983                    StringBundler msg = new StringBundler(4);
2984    
2985                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2986    
2987                    msg.append("companyId=");
2988                    msg.append(companyId);
2989    
2990                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2991    
2992                    throw new NoSuchArticleException(msg.toString());
2993            }
2994    
2995            /**
2996             * Returns the last journal article in the ordered set where companyId = &#63;.
2997             *
2998             * @param companyId the company ID
2999             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3000             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
3001             * @throws SystemException if a system exception occurred
3002             */
3003            public JournalArticle fetchByCompanyId_Last(long companyId,
3004                    OrderByComparator orderByComparator) throws SystemException {
3005                    int count = countByCompanyId(companyId);
3006    
3007                    List<JournalArticle> list = findByCompanyId(companyId, count - 1,
3008                                    count, orderByComparator);
3009    
3010                    if (!list.isEmpty()) {
3011                            return list.get(0);
3012                    }
3013    
3014                    return null;
3015            }
3016    
3017            /**
3018             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63;.
3019             *
3020             * @param id the primary key of the current journal article
3021             * @param companyId the company ID
3022             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3023             * @return the previous, current, and next journal article
3024             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
3025             * @throws SystemException if a system exception occurred
3026             */
3027            public JournalArticle[] findByCompanyId_PrevAndNext(long id,
3028                    long companyId, OrderByComparator orderByComparator)
3029                    throws NoSuchArticleException, SystemException {
3030                    JournalArticle journalArticle = findByPrimaryKey(id);
3031    
3032                    Session session = null;
3033    
3034                    try {
3035                            session = openSession();
3036    
3037                            JournalArticle[] array = new JournalArticleImpl[3];
3038    
3039                            array[0] = getByCompanyId_PrevAndNext(session, journalArticle,
3040                                            companyId, orderByComparator, true);
3041    
3042                            array[1] = journalArticle;
3043    
3044                            array[2] = getByCompanyId_PrevAndNext(session, journalArticle,
3045                                            companyId, orderByComparator, false);
3046    
3047                            return array;
3048                    }
3049                    catch (Exception e) {
3050                            throw processException(e);
3051                    }
3052                    finally {
3053                            closeSession(session);
3054                    }
3055            }
3056    
3057            protected JournalArticle getByCompanyId_PrevAndNext(Session session,
3058                    JournalArticle journalArticle, long companyId,
3059                    OrderByComparator orderByComparator, boolean previous) {
3060                    StringBundler query = null;
3061    
3062                    if (orderByComparator != null) {
3063                            query = new StringBundler(6 +
3064                                            (orderByComparator.getOrderByFields().length * 6));
3065                    }
3066                    else {
3067                            query = new StringBundler(3);
3068                    }
3069    
3070                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3071    
3072                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3073    
3074                    if (orderByComparator != null) {
3075                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3076    
3077                            if (orderByConditionFields.length > 0) {
3078                                    query.append(WHERE_AND);
3079                            }
3080    
3081                            for (int i = 0; i < orderByConditionFields.length; i++) {
3082                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3083                                    query.append(orderByConditionFields[i]);
3084    
3085                                    if ((i + 1) < orderByConditionFields.length) {
3086                                            if (orderByComparator.isAscending() ^ previous) {
3087                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3088                                            }
3089                                            else {
3090                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3091                                            }
3092                                    }
3093                                    else {
3094                                            if (orderByComparator.isAscending() ^ previous) {
3095                                                    query.append(WHERE_GREATER_THAN);
3096                                            }
3097                                            else {
3098                                                    query.append(WHERE_LESSER_THAN);
3099                                            }
3100                                    }
3101                            }
3102    
3103                            query.append(ORDER_BY_CLAUSE);
3104    
3105                            String[] orderByFields = orderByComparator.getOrderByFields();
3106    
3107                            for (int i = 0; i < orderByFields.length; i++) {
3108                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3109                                    query.append(orderByFields[i]);
3110    
3111                                    if ((i + 1) < orderByFields.length) {
3112                                            if (orderByComparator.isAscending() ^ previous) {
3113                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3114                                            }
3115                                            else {
3116                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3117                                            }
3118                                    }
3119                                    else {
3120                                            if (orderByComparator.isAscending() ^ previous) {
3121                                                    query.append(ORDER_BY_ASC);
3122                                            }
3123                                            else {
3124                                                    query.append(ORDER_BY_DESC);
3125                                            }
3126                                    }
3127                            }
3128                    }
3129                    else {
3130                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3131                    }
3132    
3133                    String sql = query.toString();
3134    
3135                    Query q = session.createQuery(sql);
3136    
3137                    q.setFirstResult(0);
3138                    q.setMaxResults(2);
3139    
3140                    QueryPos qPos = QueryPos.getInstance(q);
3141    
3142                    qPos.add(companyId);
3143    
3144                    if (orderByComparator != null) {
3145                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
3146    
3147                            for (Object value : values) {
3148                                    qPos.add(value);
3149                            }
3150                    }
3151    
3152                    List<JournalArticle> list = q.list();
3153    
3154                    if (list.size() == 2) {
3155                            return list.get(1);
3156                    }
3157                    else {
3158                            return null;
3159                    }
3160            }
3161    
3162            /**
3163             * Removes all the journal articles where companyId = &#63; from the database.
3164             *
3165             * @param companyId the company ID
3166             * @throws SystemException if a system exception occurred
3167             */
3168            public void removeByCompanyId(long companyId) throws SystemException {
3169                    for (JournalArticle journalArticle : findByCompanyId(companyId,
3170                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3171                            remove(journalArticle);
3172                    }
3173            }
3174    
3175            /**
3176             * Returns the number of journal articles where companyId = &#63;.
3177             *
3178             * @param companyId the company ID
3179             * @return the number of matching journal articles
3180             * @throws SystemException if a system exception occurred
3181             */
3182            public int countByCompanyId(long companyId) throws SystemException {
3183                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
3184    
3185                    Object[] finderArgs = new Object[] { companyId };
3186    
3187                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3188                                    this);
3189    
3190                    if (count == null) {
3191                            StringBundler query = new StringBundler(2);
3192    
3193                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
3194    
3195                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3196    
3197                            String sql = query.toString();
3198    
3199                            Session session = null;
3200    
3201                            try {
3202                                    session = openSession();
3203    
3204                                    Query q = session.createQuery(sql);
3205    
3206                                    QueryPos qPos = QueryPos.getInstance(q);
3207    
3208                                    qPos.add(companyId);
3209    
3210                                    count = (Long)q.uniqueResult();
3211    
3212                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3213                            }
3214                            catch (Exception e) {
3215                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3216    
3217                                    throw processException(e);
3218                            }
3219                            finally {
3220                                    closeSession(session);
3221                            }
3222                    }
3223    
3224                    return count.intValue();
3225            }
3226    
3227            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "journalArticle.companyId = ?";
3228            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID =
3229                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3230                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
3231                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
3232                            "findByStructureId",
3233                            new String[] {
3234                                    String.class.getName(),
3235                                    
3236                            Integer.class.getName(), Integer.class.getName(),
3237                                    OrderByComparator.class.getName()
3238                            });
3239            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID =
3240                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3241                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
3242                            JournalArticleImpl.class,
3243                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByStructureId",
3244                            new String[] { String.class.getName() },
3245                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK |
3246                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
3247                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
3248            public static final FinderPath FINDER_PATH_COUNT_BY_STRUCTUREID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3249                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
3250                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByStructureId",
3251                            new String[] { String.class.getName() });
3252    
3253            /**
3254             * Returns all the journal articles where structureId = &#63;.
3255             *
3256             * @param structureId the structure ID
3257             * @return the matching journal articles
3258             * @throws SystemException if a system exception occurred
3259             */
3260            public List<JournalArticle> findByStructureId(String structureId)
3261                    throws SystemException {
3262                    return findByStructureId(structureId, QueryUtil.ALL_POS,
3263                            QueryUtil.ALL_POS, null);
3264            }
3265    
3266            /**
3267             * Returns a range of all the journal articles where structureId = &#63;.
3268             *
3269             * <p>
3270             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3271             * </p>
3272             *
3273             * @param structureId the structure ID
3274             * @param start the lower bound of the range of journal articles
3275             * @param end the upper bound of the range of journal articles (not inclusive)
3276             * @return the range of matching journal articles
3277             * @throws SystemException if a system exception occurred
3278             */
3279            public List<JournalArticle> findByStructureId(String structureId,
3280                    int start, int end) throws SystemException {
3281                    return findByStructureId(structureId, start, end, null);
3282            }
3283    
3284            /**
3285             * Returns an ordered range of all the journal articles where structureId = &#63;.
3286             *
3287             * <p>
3288             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3289             * </p>
3290             *
3291             * @param structureId the structure ID
3292             * @param start the lower bound of the range of journal articles
3293             * @param end the upper bound of the range of journal articles (not inclusive)
3294             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3295             * @return the ordered range of matching journal articles
3296             * @throws SystemException if a system exception occurred
3297             */
3298            public List<JournalArticle> findByStructureId(String structureId,
3299                    int start, int end, OrderByComparator orderByComparator)
3300                    throws SystemException {
3301                    boolean pagination = true;
3302                    FinderPath finderPath = null;
3303                    Object[] finderArgs = null;
3304    
3305                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3306                                    (orderByComparator == null)) {
3307                            pagination = false;
3308                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID;
3309                            finderArgs = new Object[] { structureId };
3310                    }
3311                    else {
3312                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID;
3313                            finderArgs = new Object[] { structureId, start, end, orderByComparator };
3314                    }
3315    
3316                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
3317                                    finderArgs, this);
3318    
3319                    if ((list != null) && !list.isEmpty()) {
3320                            for (JournalArticle journalArticle : list) {
3321                                    if (!Validator.equals(structureId,
3322                                                            journalArticle.getStructureId())) {
3323                                            list = null;
3324    
3325                                            break;
3326                                    }
3327                            }
3328                    }
3329    
3330                    if (list == null) {
3331                            StringBundler query = null;
3332    
3333                            if (orderByComparator != null) {
3334                                    query = new StringBundler(3 +
3335                                                    (orderByComparator.getOrderByFields().length * 3));
3336                            }
3337                            else {
3338                                    query = new StringBundler(3);
3339                            }
3340    
3341                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3342    
3343                            if (structureId == null) {
3344                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
3345                            }
3346                            else {
3347                                    if (structureId.equals(StringPool.BLANK)) {
3348                                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
3349                                    }
3350                                    else {
3351                                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
3352                                    }
3353                            }
3354    
3355                            if (orderByComparator != null) {
3356                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3357                                            orderByComparator);
3358                            }
3359                            else
3360                             if (pagination) {
3361                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3362                            }
3363    
3364                            String sql = query.toString();
3365    
3366                            Session session = null;
3367    
3368                            try {
3369                                    session = openSession();
3370    
3371                                    Query q = session.createQuery(sql);
3372    
3373                                    QueryPos qPos = QueryPos.getInstance(q);
3374    
3375                                    if (structureId != null) {
3376                                            qPos.add(structureId);
3377                                    }
3378    
3379                                    if (!pagination) {
3380                                            list = (List<JournalArticle>)QueryUtil.list(q,
3381                                                            getDialect(), start, end, false);
3382    
3383                                            Collections.sort(list);
3384    
3385                                            list = new UnmodifiableList<JournalArticle>(list);
3386                                    }
3387                                    else {
3388                                            list = (List<JournalArticle>)QueryUtil.list(q,
3389                                                            getDialect(), start, end);
3390                                    }
3391    
3392                                    cacheResult(list);
3393    
3394                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3395                            }
3396                            catch (Exception e) {
3397                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3398    
3399                                    throw processException(e);
3400                            }
3401                            finally {
3402                                    closeSession(session);
3403                            }
3404                    }
3405    
3406                    return list;
3407            }
3408    
3409            /**
3410             * Returns the first journal article in the ordered set where structureId = &#63;.
3411             *
3412             * @param structureId the structure ID
3413             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3414             * @return the first matching journal article
3415             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3416             * @throws SystemException if a system exception occurred
3417             */
3418            public JournalArticle findByStructureId_First(String structureId,
3419                    OrderByComparator orderByComparator)
3420                    throws NoSuchArticleException, SystemException {
3421                    JournalArticle journalArticle = fetchByStructureId_First(structureId,
3422                                    orderByComparator);
3423    
3424                    if (journalArticle != null) {
3425                            return journalArticle;
3426                    }
3427    
3428                    StringBundler msg = new StringBundler(4);
3429    
3430                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3431    
3432                    msg.append("structureId=");
3433                    msg.append(structureId);
3434    
3435                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3436    
3437                    throw new NoSuchArticleException(msg.toString());
3438            }
3439    
3440            /**
3441             * Returns the first journal article in the ordered set where structureId = &#63;.
3442             *
3443             * @param structureId the structure ID
3444             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3445             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
3446             * @throws SystemException if a system exception occurred
3447             */
3448            public JournalArticle fetchByStructureId_First(String structureId,
3449                    OrderByComparator orderByComparator) throws SystemException {
3450                    List<JournalArticle> list = findByStructureId(structureId, 0, 1,
3451                                    orderByComparator);
3452    
3453                    if (!list.isEmpty()) {
3454                            return list.get(0);
3455                    }
3456    
3457                    return null;
3458            }
3459    
3460            /**
3461             * Returns the last journal article in the ordered set where structureId = &#63;.
3462             *
3463             * @param structureId the structure ID
3464             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3465             * @return the last matching journal article
3466             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3467             * @throws SystemException if a system exception occurred
3468             */
3469            public JournalArticle findByStructureId_Last(String structureId,
3470                    OrderByComparator orderByComparator)
3471                    throws NoSuchArticleException, SystemException {
3472                    JournalArticle journalArticle = fetchByStructureId_Last(structureId,
3473                                    orderByComparator);
3474    
3475                    if (journalArticle != null) {
3476                            return journalArticle;
3477                    }
3478    
3479                    StringBundler msg = new StringBundler(4);
3480    
3481                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3482    
3483                    msg.append("structureId=");
3484                    msg.append(structureId);
3485    
3486                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3487    
3488                    throw new NoSuchArticleException(msg.toString());
3489            }
3490    
3491            /**
3492             * Returns the last journal article in the ordered set where structureId = &#63;.
3493             *
3494             * @param structureId the structure ID
3495             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3496             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
3497             * @throws SystemException if a system exception occurred
3498             */
3499            public JournalArticle fetchByStructureId_Last(String structureId,
3500                    OrderByComparator orderByComparator) throws SystemException {
3501                    int count = countByStructureId(structureId);
3502    
3503                    List<JournalArticle> list = findByStructureId(structureId, count - 1,
3504                                    count, orderByComparator);
3505    
3506                    if (!list.isEmpty()) {
3507                            return list.get(0);
3508                    }
3509    
3510                    return null;
3511            }
3512    
3513            /**
3514             * Returns the journal articles before and after the current journal article in the ordered set where structureId = &#63;.
3515             *
3516             * @param id the primary key of the current journal article
3517             * @param structureId the structure ID
3518             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3519             * @return the previous, current, and next journal article
3520             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
3521             * @throws SystemException if a system exception occurred
3522             */
3523            public JournalArticle[] findByStructureId_PrevAndNext(long id,
3524                    String structureId, OrderByComparator orderByComparator)
3525                    throws NoSuchArticleException, SystemException {
3526                    JournalArticle journalArticle = findByPrimaryKey(id);
3527    
3528                    Session session = null;
3529    
3530                    try {
3531                            session = openSession();
3532    
3533                            JournalArticle[] array = new JournalArticleImpl[3];
3534    
3535                            array[0] = getByStructureId_PrevAndNext(session, journalArticle,
3536                                            structureId, orderByComparator, true);
3537    
3538                            array[1] = journalArticle;
3539    
3540                            array[2] = getByStructureId_PrevAndNext(session, journalArticle,
3541                                            structureId, orderByComparator, false);
3542    
3543                            return array;
3544                    }
3545                    catch (Exception e) {
3546                            throw processException(e);
3547                    }
3548                    finally {
3549                            closeSession(session);
3550                    }
3551            }
3552    
3553            protected JournalArticle getByStructureId_PrevAndNext(Session session,
3554                    JournalArticle journalArticle, String structureId,
3555                    OrderByComparator orderByComparator, boolean previous) {
3556                    StringBundler query = null;
3557    
3558                    if (orderByComparator != null) {
3559                            query = new StringBundler(6 +
3560                                            (orderByComparator.getOrderByFields().length * 6));
3561                    }
3562                    else {
3563                            query = new StringBundler(3);
3564                    }
3565    
3566                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3567    
3568                    if (structureId == null) {
3569                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
3570                    }
3571                    else {
3572                            if (structureId.equals(StringPool.BLANK)) {
3573                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
3574                            }
3575                            else {
3576                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
3577                            }
3578                    }
3579    
3580                    if (orderByComparator != null) {
3581                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3582    
3583                            if (orderByConditionFields.length > 0) {
3584                                    query.append(WHERE_AND);
3585                            }
3586    
3587                            for (int i = 0; i < orderByConditionFields.length; i++) {
3588                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3589                                    query.append(orderByConditionFields[i]);
3590    
3591                                    if ((i + 1) < orderByConditionFields.length) {
3592                                            if (orderByComparator.isAscending() ^ previous) {
3593                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3594                                            }
3595                                            else {
3596                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3597                                            }
3598                                    }
3599                                    else {
3600                                            if (orderByComparator.isAscending() ^ previous) {
3601                                                    query.append(WHERE_GREATER_THAN);
3602                                            }
3603                                            else {
3604                                                    query.append(WHERE_LESSER_THAN);
3605                                            }
3606                                    }
3607                            }
3608    
3609                            query.append(ORDER_BY_CLAUSE);
3610    
3611                            String[] orderByFields = orderByComparator.getOrderByFields();
3612    
3613                            for (int i = 0; i < orderByFields.length; i++) {
3614                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3615                                    query.append(orderByFields[i]);
3616    
3617                                    if ((i + 1) < orderByFields.length) {
3618                                            if (orderByComparator.isAscending() ^ previous) {
3619                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3620                                            }
3621                                            else {
3622                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3623                                            }
3624                                    }
3625                                    else {
3626                                            if (orderByComparator.isAscending() ^ previous) {
3627                                                    query.append(ORDER_BY_ASC);
3628                                            }
3629                                            else {
3630                                                    query.append(ORDER_BY_DESC);
3631                                            }
3632                                    }
3633                            }
3634                    }
3635                    else {
3636                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3637                    }
3638    
3639                    String sql = query.toString();
3640    
3641                    Query q = session.createQuery(sql);
3642    
3643                    q.setFirstResult(0);
3644                    q.setMaxResults(2);
3645    
3646                    QueryPos qPos = QueryPos.getInstance(q);
3647    
3648                    if (structureId != null) {
3649                            qPos.add(structureId);
3650                    }
3651    
3652                    if (orderByComparator != null) {
3653                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
3654    
3655                            for (Object value : values) {
3656                                    qPos.add(value);
3657                            }
3658                    }
3659    
3660                    List<JournalArticle> list = q.list();
3661    
3662                    if (list.size() == 2) {
3663                            return list.get(1);
3664                    }
3665                    else {
3666                            return null;
3667                    }
3668            }
3669    
3670            /**
3671             * Removes all the journal articles where structureId = &#63; from the database.
3672             *
3673             * @param structureId the structure ID
3674             * @throws SystemException if a system exception occurred
3675             */
3676            public void removeByStructureId(String structureId)
3677                    throws SystemException {
3678                    for (JournalArticle journalArticle : findByStructureId(structureId,
3679                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3680                            remove(journalArticle);
3681                    }
3682            }
3683    
3684            /**
3685             * Returns the number of journal articles where structureId = &#63;.
3686             *
3687             * @param structureId the structure ID
3688             * @return the number of matching journal articles
3689             * @throws SystemException if a system exception occurred
3690             */
3691            public int countByStructureId(String structureId) throws SystemException {
3692                    FinderPath finderPath = FINDER_PATH_COUNT_BY_STRUCTUREID;
3693    
3694                    Object[] finderArgs = new Object[] { structureId };
3695    
3696                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3697                                    this);
3698    
3699                    if (count == null) {
3700                            StringBundler query = new StringBundler(2);
3701    
3702                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
3703    
3704                            if (structureId == null) {
3705                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
3706                            }
3707                            else {
3708                                    if (structureId.equals(StringPool.BLANK)) {
3709                                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
3710                                    }
3711                                    else {
3712                                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
3713                                    }
3714                            }
3715    
3716                            String sql = query.toString();
3717    
3718                            Session session = null;
3719    
3720                            try {
3721                                    session = openSession();
3722    
3723                                    Query q = session.createQuery(sql);
3724    
3725                                    QueryPos qPos = QueryPos.getInstance(q);
3726    
3727                                    if (structureId != null) {
3728                                            qPos.add(structureId);
3729                                    }
3730    
3731                                    count = (Long)q.uniqueResult();
3732    
3733                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3734                            }
3735                            catch (Exception e) {
3736                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3737    
3738                                    throw processException(e);
3739                            }
3740                            finally {
3741                                    closeSession(session);
3742                            }
3743                    }
3744    
3745                    return count.intValue();
3746            }
3747    
3748            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
3749            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2 = "journalArticle.structureId = ?";
3750            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = ?)";
3751            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_TEMPLATEID =
3752                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3753                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
3754                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
3755                            "findByTemplateId",
3756                            new String[] {
3757                                    String.class.getName(),
3758                                    
3759                            Integer.class.getName(), Integer.class.getName(),
3760                                    OrderByComparator.class.getName()
3761                            });
3762            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID =
3763                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3764                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
3765                            JournalArticleImpl.class,
3766                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByTemplateId",
3767                            new String[] { String.class.getName() },
3768                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK |
3769                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
3770                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
3771            public static final FinderPath FINDER_PATH_COUNT_BY_TEMPLATEID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3772                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
3773                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByTemplateId",
3774                            new String[] { String.class.getName() });
3775    
3776            /**
3777             * Returns all the journal articles where templateId = &#63;.
3778             *
3779             * @param templateId the template ID
3780             * @return the matching journal articles
3781             * @throws SystemException if a system exception occurred
3782             */
3783            public List<JournalArticle> findByTemplateId(String templateId)
3784                    throws SystemException {
3785                    return findByTemplateId(templateId, QueryUtil.ALL_POS,
3786                            QueryUtil.ALL_POS, null);
3787            }
3788    
3789            /**
3790             * Returns a range of all the journal articles where templateId = &#63;.
3791             *
3792             * <p>
3793             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3794             * </p>
3795             *
3796             * @param templateId the template ID
3797             * @param start the lower bound of the range of journal articles
3798             * @param end the upper bound of the range of journal articles (not inclusive)
3799             * @return the range of matching journal articles
3800             * @throws SystemException if a system exception occurred
3801             */
3802            public List<JournalArticle> findByTemplateId(String templateId, int start,
3803                    int end) throws SystemException {
3804                    return findByTemplateId(templateId, start, end, null);
3805            }
3806    
3807            /**
3808             * Returns an ordered range of all the journal articles where templateId = &#63;.
3809             *
3810             * <p>
3811             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3812             * </p>
3813             *
3814             * @param templateId the template ID
3815             * @param start the lower bound of the range of journal articles
3816             * @param end the upper bound of the range of journal articles (not inclusive)
3817             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3818             * @return the ordered range of matching journal articles
3819             * @throws SystemException if a system exception occurred
3820             */
3821            public List<JournalArticle> findByTemplateId(String templateId, int start,
3822                    int end, OrderByComparator orderByComparator) throws SystemException {
3823                    boolean pagination = true;
3824                    FinderPath finderPath = null;
3825                    Object[] finderArgs = null;
3826    
3827                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3828                                    (orderByComparator == null)) {
3829                            pagination = false;
3830                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID;
3831                            finderArgs = new Object[] { templateId };
3832                    }
3833                    else {
3834                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_TEMPLATEID;
3835                            finderArgs = new Object[] { templateId, start, end, orderByComparator };
3836                    }
3837    
3838                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
3839                                    finderArgs, this);
3840    
3841                    if ((list != null) && !list.isEmpty()) {
3842                            for (JournalArticle journalArticle : list) {
3843                                    if (!Validator.equals(templateId, journalArticle.getTemplateId())) {
3844                                            list = null;
3845    
3846                                            break;
3847                                    }
3848                            }
3849                    }
3850    
3851                    if (list == null) {
3852                            StringBundler query = null;
3853    
3854                            if (orderByComparator != null) {
3855                                    query = new StringBundler(3 +
3856                                                    (orderByComparator.getOrderByFields().length * 3));
3857                            }
3858                            else {
3859                                    query = new StringBundler(3);
3860                            }
3861    
3862                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3863    
3864                            if (templateId == null) {
3865                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
3866                            }
3867                            else {
3868                                    if (templateId.equals(StringPool.BLANK)) {
3869                                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
3870                                    }
3871                                    else {
3872                                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
3873                                    }
3874                            }
3875    
3876                            if (orderByComparator != null) {
3877                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3878                                            orderByComparator);
3879                            }
3880                            else
3881                             if (pagination) {
3882                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3883                            }
3884    
3885                            String sql = query.toString();
3886    
3887                            Session session = null;
3888    
3889                            try {
3890                                    session = openSession();
3891    
3892                                    Query q = session.createQuery(sql);
3893    
3894                                    QueryPos qPos = QueryPos.getInstance(q);
3895    
3896                                    if (templateId != null) {
3897                                            qPos.add(templateId);
3898                                    }
3899    
3900                                    if (!pagination) {
3901                                            list = (List<JournalArticle>)QueryUtil.list(q,
3902                                                            getDialect(), start, end, false);
3903    
3904                                            Collections.sort(list);
3905    
3906                                            list = new UnmodifiableList<JournalArticle>(list);
3907                                    }
3908                                    else {
3909                                            list = (List<JournalArticle>)QueryUtil.list(q,
3910                                                            getDialect(), start, end);
3911                                    }
3912    
3913                                    cacheResult(list);
3914    
3915                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3916                            }
3917                            catch (Exception e) {
3918                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3919    
3920                                    throw processException(e);
3921                            }
3922                            finally {
3923                                    closeSession(session);
3924                            }
3925                    }
3926    
3927                    return list;
3928            }
3929    
3930            /**
3931             * Returns the first journal article in the ordered set where templateId = &#63;.
3932             *
3933             * @param templateId the template ID
3934             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3935             * @return the first matching journal article
3936             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3937             * @throws SystemException if a system exception occurred
3938             */
3939            public JournalArticle findByTemplateId_First(String templateId,
3940                    OrderByComparator orderByComparator)
3941                    throws NoSuchArticleException, SystemException {
3942                    JournalArticle journalArticle = fetchByTemplateId_First(templateId,
3943                                    orderByComparator);
3944    
3945                    if (journalArticle != null) {
3946                            return journalArticle;
3947                    }
3948    
3949                    StringBundler msg = new StringBundler(4);
3950    
3951                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3952    
3953                    msg.append("templateId=");
3954                    msg.append(templateId);
3955    
3956                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3957    
3958                    throw new NoSuchArticleException(msg.toString());
3959            }
3960    
3961            /**
3962             * Returns the first journal article in the ordered set where templateId = &#63;.
3963             *
3964             * @param templateId the template ID
3965             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3966             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
3967             * @throws SystemException if a system exception occurred
3968             */
3969            public JournalArticle fetchByTemplateId_First(String templateId,
3970                    OrderByComparator orderByComparator) throws SystemException {
3971                    List<JournalArticle> list = findByTemplateId(templateId, 0, 1,
3972                                    orderByComparator);
3973    
3974                    if (!list.isEmpty()) {
3975                            return list.get(0);
3976                    }
3977    
3978                    return null;
3979            }
3980    
3981            /**
3982             * Returns the last journal article in the ordered set where templateId = &#63;.
3983             *
3984             * @param templateId the template ID
3985             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3986             * @return the last matching journal article
3987             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3988             * @throws SystemException if a system exception occurred
3989             */
3990            public JournalArticle findByTemplateId_Last(String templateId,
3991                    OrderByComparator orderByComparator)
3992                    throws NoSuchArticleException, SystemException {
3993                    JournalArticle journalArticle = fetchByTemplateId_Last(templateId,
3994                                    orderByComparator);
3995    
3996                    if (journalArticle != null) {
3997                            return journalArticle;
3998                    }
3999    
4000                    StringBundler msg = new StringBundler(4);
4001    
4002                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4003    
4004                    msg.append("templateId=");
4005                    msg.append(templateId);
4006    
4007                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4008    
4009                    throw new NoSuchArticleException(msg.toString());
4010            }
4011    
4012            /**
4013             * Returns the last journal article in the ordered set where templateId = &#63;.
4014             *
4015             * @param templateId the template ID
4016             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4017             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
4018             * @throws SystemException if a system exception occurred
4019             */
4020            public JournalArticle fetchByTemplateId_Last(String templateId,
4021                    OrderByComparator orderByComparator) throws SystemException {
4022                    int count = countByTemplateId(templateId);
4023    
4024                    List<JournalArticle> list = findByTemplateId(templateId, count - 1,
4025                                    count, orderByComparator);
4026    
4027                    if (!list.isEmpty()) {
4028                            return list.get(0);
4029                    }
4030    
4031                    return null;
4032            }
4033    
4034            /**
4035             * Returns the journal articles before and after the current journal article in the ordered set where templateId = &#63;.
4036             *
4037             * @param id the primary key of the current journal article
4038             * @param templateId the template ID
4039             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4040             * @return the previous, current, and next journal article
4041             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
4042             * @throws SystemException if a system exception occurred
4043             */
4044            public JournalArticle[] findByTemplateId_PrevAndNext(long id,
4045                    String templateId, OrderByComparator orderByComparator)
4046                    throws NoSuchArticleException, SystemException {
4047                    JournalArticle journalArticle = findByPrimaryKey(id);
4048    
4049                    Session session = null;
4050    
4051                    try {
4052                            session = openSession();
4053    
4054                            JournalArticle[] array = new JournalArticleImpl[3];
4055    
4056                            array[0] = getByTemplateId_PrevAndNext(session, journalArticle,
4057                                            templateId, orderByComparator, true);
4058    
4059                            array[1] = journalArticle;
4060    
4061                            array[2] = getByTemplateId_PrevAndNext(session, journalArticle,
4062                                            templateId, orderByComparator, false);
4063    
4064                            return array;
4065                    }
4066                    catch (Exception e) {
4067                            throw processException(e);
4068                    }
4069                    finally {
4070                            closeSession(session);
4071                    }
4072            }
4073    
4074            protected JournalArticle getByTemplateId_PrevAndNext(Session session,
4075                    JournalArticle journalArticle, String templateId,
4076                    OrderByComparator orderByComparator, boolean previous) {
4077                    StringBundler query = null;
4078    
4079                    if (orderByComparator != null) {
4080                            query = new StringBundler(6 +
4081                                            (orderByComparator.getOrderByFields().length * 6));
4082                    }
4083                    else {
4084                            query = new StringBundler(3);
4085                    }
4086    
4087                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4088    
4089                    if (templateId == null) {
4090                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
4091                    }
4092                    else {
4093                            if (templateId.equals(StringPool.BLANK)) {
4094                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
4095                            }
4096                            else {
4097                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
4098                            }
4099                    }
4100    
4101                    if (orderByComparator != null) {
4102                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4103    
4104                            if (orderByConditionFields.length > 0) {
4105                                    query.append(WHERE_AND);
4106                            }
4107    
4108                            for (int i = 0; i < orderByConditionFields.length; i++) {
4109                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4110                                    query.append(orderByConditionFields[i]);
4111    
4112                                    if ((i + 1) < orderByConditionFields.length) {
4113                                            if (orderByComparator.isAscending() ^ previous) {
4114                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4115                                            }
4116                                            else {
4117                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4118                                            }
4119                                    }
4120                                    else {
4121                                            if (orderByComparator.isAscending() ^ previous) {
4122                                                    query.append(WHERE_GREATER_THAN);
4123                                            }
4124                                            else {
4125                                                    query.append(WHERE_LESSER_THAN);
4126                                            }
4127                                    }
4128                            }
4129    
4130                            query.append(ORDER_BY_CLAUSE);
4131    
4132                            String[] orderByFields = orderByComparator.getOrderByFields();
4133    
4134                            for (int i = 0; i < orderByFields.length; i++) {
4135                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4136                                    query.append(orderByFields[i]);
4137    
4138                                    if ((i + 1) < orderByFields.length) {
4139                                            if (orderByComparator.isAscending() ^ previous) {
4140                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4141                                            }
4142                                            else {
4143                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4144                                            }
4145                                    }
4146                                    else {
4147                                            if (orderByComparator.isAscending() ^ previous) {
4148                                                    query.append(ORDER_BY_ASC);
4149                                            }
4150                                            else {
4151                                                    query.append(ORDER_BY_DESC);
4152                                            }
4153                                    }
4154                            }
4155                    }
4156                    else {
4157                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4158                    }
4159    
4160                    String sql = query.toString();
4161    
4162                    Query q = session.createQuery(sql);
4163    
4164                    q.setFirstResult(0);
4165                    q.setMaxResults(2);
4166    
4167                    QueryPos qPos = QueryPos.getInstance(q);
4168    
4169                    if (templateId != null) {
4170                            qPos.add(templateId);
4171                    }
4172    
4173                    if (orderByComparator != null) {
4174                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
4175    
4176                            for (Object value : values) {
4177                                    qPos.add(value);
4178                            }
4179                    }
4180    
4181                    List<JournalArticle> list = q.list();
4182    
4183                    if (list.size() == 2) {
4184                            return list.get(1);
4185                    }
4186                    else {
4187                            return null;
4188                    }
4189            }
4190    
4191            /**
4192             * Removes all the journal articles where templateId = &#63; from the database.
4193             *
4194             * @param templateId the template ID
4195             * @throws SystemException if a system exception occurred
4196             */
4197            public void removeByTemplateId(String templateId) throws SystemException {
4198                    for (JournalArticle journalArticle : findByTemplateId(templateId,
4199                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4200                            remove(journalArticle);
4201                    }
4202            }
4203    
4204            /**
4205             * Returns the number of journal articles where templateId = &#63;.
4206             *
4207             * @param templateId the template ID
4208             * @return the number of matching journal articles
4209             * @throws SystemException if a system exception occurred
4210             */
4211            public int countByTemplateId(String templateId) throws SystemException {
4212                    FinderPath finderPath = FINDER_PATH_COUNT_BY_TEMPLATEID;
4213    
4214                    Object[] finderArgs = new Object[] { templateId };
4215    
4216                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4217                                    this);
4218    
4219                    if (count == null) {
4220                            StringBundler query = new StringBundler(2);
4221    
4222                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
4223    
4224                            if (templateId == null) {
4225                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
4226                            }
4227                            else {
4228                                    if (templateId.equals(StringPool.BLANK)) {
4229                                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
4230                                    }
4231                                    else {
4232                                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
4233                                    }
4234                            }
4235    
4236                            String sql = query.toString();
4237    
4238                            Session session = null;
4239    
4240                            try {
4241                                    session = openSession();
4242    
4243                                    Query q = session.createQuery(sql);
4244    
4245                                    QueryPos qPos = QueryPos.getInstance(q);
4246    
4247                                    if (templateId != null) {
4248                                            qPos.add(templateId);
4249                                    }
4250    
4251                                    count = (Long)q.uniqueResult();
4252    
4253                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4254                            }
4255                            catch (Exception e) {
4256                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4257    
4258                                    throw processException(e);
4259                            }
4260                            finally {
4261                                    closeSession(session);
4262                            }
4263                    }
4264    
4265                    return count.intValue();
4266            }
4267    
4268            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
4269            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2 = "journalArticle.templateId = ?";
4270            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = ?)";
4271            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTUUID =
4272                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4273                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4274                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
4275                            "findByLayoutUuid",
4276                            new String[] {
4277                                    String.class.getName(),
4278                                    
4279                            Integer.class.getName(), Integer.class.getName(),
4280                                    OrderByComparator.class.getName()
4281                            });
4282            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID =
4283                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4284                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4285                            JournalArticleImpl.class,
4286                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByLayoutUuid",
4287                            new String[] { String.class.getName() },
4288                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK |
4289                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
4290                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
4291            public static final FinderPath FINDER_PATH_COUNT_BY_LAYOUTUUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4292                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
4293                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByLayoutUuid",
4294                            new String[] { String.class.getName() });
4295    
4296            /**
4297             * Returns all the journal articles where layoutUuid = &#63;.
4298             *
4299             * @param layoutUuid the layout uuid
4300             * @return the matching journal articles
4301             * @throws SystemException if a system exception occurred
4302             */
4303            public List<JournalArticle> findByLayoutUuid(String layoutUuid)
4304                    throws SystemException {
4305                    return findByLayoutUuid(layoutUuid, QueryUtil.ALL_POS,
4306                            QueryUtil.ALL_POS, null);
4307            }
4308    
4309            /**
4310             * Returns a range of all the journal articles where layoutUuid = &#63;.
4311             *
4312             * <p>
4313             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4314             * </p>
4315             *
4316             * @param layoutUuid the layout uuid
4317             * @param start the lower bound of the range of journal articles
4318             * @param end the upper bound of the range of journal articles (not inclusive)
4319             * @return the range of matching journal articles
4320             * @throws SystemException if a system exception occurred
4321             */
4322            public List<JournalArticle> findByLayoutUuid(String layoutUuid, int start,
4323                    int end) throws SystemException {
4324                    return findByLayoutUuid(layoutUuid, start, end, null);
4325            }
4326    
4327            /**
4328             * Returns an ordered range of all the journal articles where layoutUuid = &#63;.
4329             *
4330             * <p>
4331             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4332             * </p>
4333             *
4334             * @param layoutUuid the layout uuid
4335             * @param start the lower bound of the range of journal articles
4336             * @param end the upper bound of the range of journal articles (not inclusive)
4337             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4338             * @return the ordered range of matching journal articles
4339             * @throws SystemException if a system exception occurred
4340             */
4341            public List<JournalArticle> findByLayoutUuid(String layoutUuid, int start,
4342                    int end, OrderByComparator orderByComparator) throws SystemException {
4343                    boolean pagination = true;
4344                    FinderPath finderPath = null;
4345                    Object[] finderArgs = null;
4346    
4347                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4348                                    (orderByComparator == null)) {
4349                            pagination = false;
4350                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID;
4351                            finderArgs = new Object[] { layoutUuid };
4352                    }
4353                    else {
4354                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTUUID;
4355                            finderArgs = new Object[] { layoutUuid, start, end, orderByComparator };
4356                    }
4357    
4358                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
4359                                    finderArgs, this);
4360    
4361                    if ((list != null) && !list.isEmpty()) {
4362                            for (JournalArticle journalArticle : list) {
4363                                    if (!Validator.equals(layoutUuid, journalArticle.getLayoutUuid())) {
4364                                            list = null;
4365    
4366                                            break;
4367                                    }
4368                            }
4369                    }
4370    
4371                    if (list == null) {
4372                            StringBundler query = null;
4373    
4374                            if (orderByComparator != null) {
4375                                    query = new StringBundler(3 +
4376                                                    (orderByComparator.getOrderByFields().length * 3));
4377                            }
4378                            else {
4379                                    query = new StringBundler(3);
4380                            }
4381    
4382                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4383    
4384                            if (layoutUuid == null) {
4385                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
4386                            }
4387                            else {
4388                                    if (layoutUuid.equals(StringPool.BLANK)) {
4389                                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
4390                                    }
4391                                    else {
4392                                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
4393                                    }
4394                            }
4395    
4396                            if (orderByComparator != null) {
4397                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4398                                            orderByComparator);
4399                            }
4400                            else
4401                             if (pagination) {
4402                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4403                            }
4404    
4405                            String sql = query.toString();
4406    
4407                            Session session = null;
4408    
4409                            try {
4410                                    session = openSession();
4411    
4412                                    Query q = session.createQuery(sql);
4413    
4414                                    QueryPos qPos = QueryPos.getInstance(q);
4415    
4416                                    if (layoutUuid != null) {
4417                                            qPos.add(layoutUuid);
4418                                    }
4419    
4420                                    if (!pagination) {
4421                                            list = (List<JournalArticle>)QueryUtil.list(q,
4422                                                            getDialect(), start, end, false);
4423    
4424                                            Collections.sort(list);
4425    
4426                                            list = new UnmodifiableList<JournalArticle>(list);
4427                                    }
4428                                    else {
4429                                            list = (List<JournalArticle>)QueryUtil.list(q,
4430                                                            getDialect(), start, end);
4431                                    }
4432    
4433                                    cacheResult(list);
4434    
4435                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4436                            }
4437                            catch (Exception e) {
4438                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4439    
4440                                    throw processException(e);
4441                            }
4442                            finally {
4443                                    closeSession(session);
4444                            }
4445                    }
4446    
4447                    return list;
4448            }
4449    
4450            /**
4451             * Returns the first journal article in the ordered set where layoutUuid = &#63;.
4452             *
4453             * @param layoutUuid the layout uuid
4454             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4455             * @return the first matching journal article
4456             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4457             * @throws SystemException if a system exception occurred
4458             */
4459            public JournalArticle findByLayoutUuid_First(String layoutUuid,
4460                    OrderByComparator orderByComparator)
4461                    throws NoSuchArticleException, SystemException {
4462                    JournalArticle journalArticle = fetchByLayoutUuid_First(layoutUuid,
4463                                    orderByComparator);
4464    
4465                    if (journalArticle != null) {
4466                            return journalArticle;
4467                    }
4468    
4469                    StringBundler msg = new StringBundler(4);
4470    
4471                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4472    
4473                    msg.append("layoutUuid=");
4474                    msg.append(layoutUuid);
4475    
4476                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4477    
4478                    throw new NoSuchArticleException(msg.toString());
4479            }
4480    
4481            /**
4482             * Returns the first journal article in the ordered set where layoutUuid = &#63;.
4483             *
4484             * @param layoutUuid the layout uuid
4485             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4486             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
4487             * @throws SystemException if a system exception occurred
4488             */
4489            public JournalArticle fetchByLayoutUuid_First(String layoutUuid,
4490                    OrderByComparator orderByComparator) throws SystemException {
4491                    List<JournalArticle> list = findByLayoutUuid(layoutUuid, 0, 1,
4492                                    orderByComparator);
4493    
4494                    if (!list.isEmpty()) {
4495                            return list.get(0);
4496                    }
4497    
4498                    return null;
4499            }
4500    
4501            /**
4502             * Returns the last journal article in the ordered set where layoutUuid = &#63;.
4503             *
4504             * @param layoutUuid the layout uuid
4505             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4506             * @return the last matching journal article
4507             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4508             * @throws SystemException if a system exception occurred
4509             */
4510            public JournalArticle findByLayoutUuid_Last(String layoutUuid,
4511                    OrderByComparator orderByComparator)
4512                    throws NoSuchArticleException, SystemException {
4513                    JournalArticle journalArticle = fetchByLayoutUuid_Last(layoutUuid,
4514                                    orderByComparator);
4515    
4516                    if (journalArticle != null) {
4517                            return journalArticle;
4518                    }
4519    
4520                    StringBundler msg = new StringBundler(4);
4521    
4522                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4523    
4524                    msg.append("layoutUuid=");
4525                    msg.append(layoutUuid);
4526    
4527                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4528    
4529                    throw new NoSuchArticleException(msg.toString());
4530            }
4531    
4532            /**
4533             * Returns the last journal article in the ordered set where layoutUuid = &#63;.
4534             *
4535             * @param layoutUuid the layout uuid
4536             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4537             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
4538             * @throws SystemException if a system exception occurred
4539             */
4540            public JournalArticle fetchByLayoutUuid_Last(String layoutUuid,
4541                    OrderByComparator orderByComparator) throws SystemException {
4542                    int count = countByLayoutUuid(layoutUuid);
4543    
4544                    List<JournalArticle> list = findByLayoutUuid(layoutUuid, count - 1,
4545                                    count, orderByComparator);
4546    
4547                    if (!list.isEmpty()) {
4548                            return list.get(0);
4549                    }
4550    
4551                    return null;
4552            }
4553    
4554            /**
4555             * Returns the journal articles before and after the current journal article in the ordered set where layoutUuid = &#63;.
4556             *
4557             * @param id the primary key of the current journal article
4558             * @param layoutUuid the layout uuid
4559             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4560             * @return the previous, current, and next journal article
4561             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
4562             * @throws SystemException if a system exception occurred
4563             */
4564            public JournalArticle[] findByLayoutUuid_PrevAndNext(long id,
4565                    String layoutUuid, OrderByComparator orderByComparator)
4566                    throws NoSuchArticleException, SystemException {
4567                    JournalArticle journalArticle = findByPrimaryKey(id);
4568    
4569                    Session session = null;
4570    
4571                    try {
4572                            session = openSession();
4573    
4574                            JournalArticle[] array = new JournalArticleImpl[3];
4575    
4576                            array[0] = getByLayoutUuid_PrevAndNext(session, journalArticle,
4577                                            layoutUuid, orderByComparator, true);
4578    
4579                            array[1] = journalArticle;
4580    
4581                            array[2] = getByLayoutUuid_PrevAndNext(session, journalArticle,
4582                                            layoutUuid, orderByComparator, false);
4583    
4584                            return array;
4585                    }
4586                    catch (Exception e) {
4587                            throw processException(e);
4588                    }
4589                    finally {
4590                            closeSession(session);
4591                    }
4592            }
4593    
4594            protected JournalArticle getByLayoutUuid_PrevAndNext(Session session,
4595                    JournalArticle journalArticle, String layoutUuid,
4596                    OrderByComparator orderByComparator, boolean previous) {
4597                    StringBundler query = null;
4598    
4599                    if (orderByComparator != null) {
4600                            query = new StringBundler(6 +
4601                                            (orderByComparator.getOrderByFields().length * 6));
4602                    }
4603                    else {
4604                            query = new StringBundler(3);
4605                    }
4606    
4607                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4608    
4609                    if (layoutUuid == null) {
4610                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
4611                    }
4612                    else {
4613                            if (layoutUuid.equals(StringPool.BLANK)) {
4614                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
4615                            }
4616                            else {
4617                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
4618                            }
4619                    }
4620    
4621                    if (orderByComparator != null) {
4622                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4623    
4624                            if (orderByConditionFields.length > 0) {
4625                                    query.append(WHERE_AND);
4626                            }
4627    
4628                            for (int i = 0; i < orderByConditionFields.length; i++) {
4629                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4630                                    query.append(orderByConditionFields[i]);
4631    
4632                                    if ((i + 1) < orderByConditionFields.length) {
4633                                            if (orderByComparator.isAscending() ^ previous) {
4634                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4635                                            }
4636                                            else {
4637                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4638                                            }
4639                                    }
4640                                    else {
4641                                            if (orderByComparator.isAscending() ^ previous) {
4642                                                    query.append(WHERE_GREATER_THAN);
4643                                            }
4644                                            else {
4645                                                    query.append(WHERE_LESSER_THAN);
4646                                            }
4647                                    }
4648                            }
4649    
4650                            query.append(ORDER_BY_CLAUSE);
4651    
4652                            String[] orderByFields = orderByComparator.getOrderByFields();
4653    
4654                            for (int i = 0; i < orderByFields.length; i++) {
4655                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4656                                    query.append(orderByFields[i]);
4657    
4658                                    if ((i + 1) < orderByFields.length) {
4659                                            if (orderByComparator.isAscending() ^ previous) {
4660                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4661                                            }
4662                                            else {
4663                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4664                                            }
4665                                    }
4666                                    else {
4667                                            if (orderByComparator.isAscending() ^ previous) {
4668                                                    query.append(ORDER_BY_ASC);
4669                                            }
4670                                            else {
4671                                                    query.append(ORDER_BY_DESC);
4672                                            }
4673                                    }
4674                            }
4675                    }
4676                    else {
4677                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4678                    }
4679    
4680                    String sql = query.toString();
4681    
4682                    Query q = session.createQuery(sql);
4683    
4684                    q.setFirstResult(0);
4685                    q.setMaxResults(2);
4686    
4687                    QueryPos qPos = QueryPos.getInstance(q);
4688    
4689                    if (layoutUuid != null) {
4690                            qPos.add(layoutUuid);
4691                    }
4692    
4693                    if (orderByComparator != null) {
4694                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
4695    
4696                            for (Object value : values) {
4697                                    qPos.add(value);
4698                            }
4699                    }
4700    
4701                    List<JournalArticle> list = q.list();
4702    
4703                    if (list.size() == 2) {
4704                            return list.get(1);
4705                    }
4706                    else {
4707                            return null;
4708                    }
4709            }
4710    
4711            /**
4712             * Removes all the journal articles where layoutUuid = &#63; from the database.
4713             *
4714             * @param layoutUuid the layout uuid
4715             * @throws SystemException if a system exception occurred
4716             */
4717            public void removeByLayoutUuid(String layoutUuid) throws SystemException {
4718                    for (JournalArticle journalArticle : findByLayoutUuid(layoutUuid,
4719                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4720                            remove(journalArticle);
4721                    }
4722            }
4723    
4724            /**
4725             * Returns the number of journal articles where layoutUuid = &#63;.
4726             *
4727             * @param layoutUuid the layout uuid
4728             * @return the number of matching journal articles
4729             * @throws SystemException if a system exception occurred
4730             */
4731            public int countByLayoutUuid(String layoutUuid) throws SystemException {
4732                    FinderPath finderPath = FINDER_PATH_COUNT_BY_LAYOUTUUID;
4733    
4734                    Object[] finderArgs = new Object[] { layoutUuid };
4735    
4736                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4737                                    this);
4738    
4739                    if (count == null) {
4740                            StringBundler query = new StringBundler(2);
4741    
4742                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
4743    
4744                            if (layoutUuid == null) {
4745                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
4746                            }
4747                            else {
4748                                    if (layoutUuid.equals(StringPool.BLANK)) {
4749                                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
4750                                    }
4751                                    else {
4752                                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
4753                                    }
4754                            }
4755    
4756                            String sql = query.toString();
4757    
4758                            Session session = null;
4759    
4760                            try {
4761                                    session = openSession();
4762    
4763                                    Query q = session.createQuery(sql);
4764    
4765                                    QueryPos qPos = QueryPos.getInstance(q);
4766    
4767                                    if (layoutUuid != null) {
4768                                            qPos.add(layoutUuid);
4769                                    }
4770    
4771                                    count = (Long)q.uniqueResult();
4772    
4773                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4774                            }
4775                            catch (Exception e) {
4776                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4777    
4778                                    throw processException(e);
4779                            }
4780                            finally {
4781                                    closeSession(session);
4782                            }
4783                    }
4784    
4785                    return count.intValue();
4786            }
4787    
4788            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
4789            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
4790            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = ?)";
4791            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_SMALLIMAGEID =
4792                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4793                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4794                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
4795                            "findBySmallImageId",
4796                            new String[] {
4797                                    Long.class.getName(),
4798                                    
4799                            Integer.class.getName(), Integer.class.getName(),
4800                                    OrderByComparator.class.getName()
4801                            });
4802            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID =
4803                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4804                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4805                            JournalArticleImpl.class,
4806                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findBySmallImageId",
4807                            new String[] { Long.class.getName() },
4808                            JournalArticleModelImpl.SMALLIMAGEID_COLUMN_BITMASK |
4809                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
4810                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
4811            public static final FinderPath FINDER_PATH_COUNT_BY_SMALLIMAGEID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4812                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
4813                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countBySmallImageId",
4814                            new String[] { Long.class.getName() });
4815    
4816            /**
4817             * Returns all the journal articles where smallImageId = &#63;.
4818             *
4819             * @param smallImageId the small image ID
4820             * @return the matching journal articles
4821             * @throws SystemException if a system exception occurred
4822             */
4823            public List<JournalArticle> findBySmallImageId(long smallImageId)
4824                    throws SystemException {
4825                    return findBySmallImageId(smallImageId, QueryUtil.ALL_POS,
4826                            QueryUtil.ALL_POS, null);
4827            }
4828    
4829            /**
4830             * Returns a range of all the journal articles where smallImageId = &#63;.
4831             *
4832             * <p>
4833             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4834             * </p>
4835             *
4836             * @param smallImageId the small image ID
4837             * @param start the lower bound of the range of journal articles
4838             * @param end the upper bound of the range of journal articles (not inclusive)
4839             * @return the range of matching journal articles
4840             * @throws SystemException if a system exception occurred
4841             */
4842            public List<JournalArticle> findBySmallImageId(long smallImageId,
4843                    int start, int end) throws SystemException {
4844                    return findBySmallImageId(smallImageId, start, end, null);
4845            }
4846    
4847            /**
4848             * Returns an ordered range of all the journal articles where smallImageId = &#63;.
4849             *
4850             * <p>
4851             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4852             * </p>
4853             *
4854             * @param smallImageId the small image ID
4855             * @param start the lower bound of the range of journal articles
4856             * @param end the upper bound of the range of journal articles (not inclusive)
4857             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4858             * @return the ordered range of matching journal articles
4859             * @throws SystemException if a system exception occurred
4860             */
4861            public List<JournalArticle> findBySmallImageId(long smallImageId,
4862                    int start, int end, OrderByComparator orderByComparator)
4863                    throws SystemException {
4864                    boolean pagination = true;
4865                    FinderPath finderPath = null;
4866                    Object[] finderArgs = null;
4867    
4868                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4869                                    (orderByComparator == null)) {
4870                            pagination = false;
4871                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID;
4872                            finderArgs = new Object[] { smallImageId };
4873                    }
4874                    else {
4875                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_SMALLIMAGEID;
4876                            finderArgs = new Object[] {
4877                                            smallImageId,
4878                                            
4879                                            start, end, orderByComparator
4880                                    };
4881                    }
4882    
4883                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
4884                                    finderArgs, this);
4885    
4886                    if ((list != null) && !list.isEmpty()) {
4887                            for (JournalArticle journalArticle : list) {
4888                                    if ((smallImageId != journalArticle.getSmallImageId())) {
4889                                            list = null;
4890    
4891                                            break;
4892                                    }
4893                            }
4894                    }
4895    
4896                    if (list == null) {
4897                            StringBundler query = null;
4898    
4899                            if (orderByComparator != null) {
4900                                    query = new StringBundler(3 +
4901                                                    (orderByComparator.getOrderByFields().length * 3));
4902                            }
4903                            else {
4904                                    query = new StringBundler(3);
4905                            }
4906    
4907                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4908    
4909                            query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
4910    
4911                            if (orderByComparator != null) {
4912                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4913                                            orderByComparator);
4914                            }
4915                            else
4916                             if (pagination) {
4917                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4918                            }
4919    
4920                            String sql = query.toString();
4921    
4922                            Session session = null;
4923    
4924                            try {
4925                                    session = openSession();
4926    
4927                                    Query q = session.createQuery(sql);
4928    
4929                                    QueryPos qPos = QueryPos.getInstance(q);
4930    
4931                                    qPos.add(smallImageId);
4932    
4933                                    if (!pagination) {
4934                                            list = (List<JournalArticle>)QueryUtil.list(q,
4935                                                            getDialect(), start, end, false);
4936    
4937                                            Collections.sort(list);
4938    
4939                                            list = new UnmodifiableList<JournalArticle>(list);
4940                                    }
4941                                    else {
4942                                            list = (List<JournalArticle>)QueryUtil.list(q,
4943                                                            getDialect(), start, end);
4944                                    }
4945    
4946                                    cacheResult(list);
4947    
4948                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4949                            }
4950                            catch (Exception e) {
4951                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4952    
4953                                    throw processException(e);
4954                            }
4955                            finally {
4956                                    closeSession(session);
4957                            }
4958                    }
4959    
4960                    return list;
4961            }
4962    
4963            /**
4964             * Returns the first journal article in the ordered set where smallImageId = &#63;.
4965             *
4966             * @param smallImageId the small image ID
4967             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4968             * @return the first matching journal article
4969             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4970             * @throws SystemException if a system exception occurred
4971             */
4972            public JournalArticle findBySmallImageId_First(long smallImageId,
4973                    OrderByComparator orderByComparator)
4974                    throws NoSuchArticleException, SystemException {
4975                    JournalArticle journalArticle = fetchBySmallImageId_First(smallImageId,
4976                                    orderByComparator);
4977    
4978                    if (journalArticle != null) {
4979                            return journalArticle;
4980                    }
4981    
4982                    StringBundler msg = new StringBundler(4);
4983    
4984                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4985    
4986                    msg.append("smallImageId=");
4987                    msg.append(smallImageId);
4988    
4989                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4990    
4991                    throw new NoSuchArticleException(msg.toString());
4992            }
4993    
4994            /**
4995             * Returns the first journal article in the ordered set where smallImageId = &#63;.
4996             *
4997             * @param smallImageId the small image ID
4998             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4999             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
5000             * @throws SystemException if a system exception occurred
5001             */
5002            public JournalArticle fetchBySmallImageId_First(long smallImageId,
5003                    OrderByComparator orderByComparator) throws SystemException {
5004                    List<JournalArticle> list = findBySmallImageId(smallImageId, 0, 1,
5005                                    orderByComparator);
5006    
5007                    if (!list.isEmpty()) {
5008                            return list.get(0);
5009                    }
5010    
5011                    return null;
5012            }
5013    
5014            /**
5015             * Returns the last journal article in the ordered set where smallImageId = &#63;.
5016             *
5017             * @param smallImageId the small image ID
5018             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5019             * @return the last matching journal article
5020             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5021             * @throws SystemException if a system exception occurred
5022             */
5023            public JournalArticle findBySmallImageId_Last(long smallImageId,
5024                    OrderByComparator orderByComparator)
5025                    throws NoSuchArticleException, SystemException {
5026                    JournalArticle journalArticle = fetchBySmallImageId_Last(smallImageId,
5027                                    orderByComparator);
5028    
5029                    if (journalArticle != null) {
5030                            return journalArticle;
5031                    }
5032    
5033                    StringBundler msg = new StringBundler(4);
5034    
5035                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5036    
5037                    msg.append("smallImageId=");
5038                    msg.append(smallImageId);
5039    
5040                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5041    
5042                    throw new NoSuchArticleException(msg.toString());
5043            }
5044    
5045            /**
5046             * Returns the last journal article in the ordered set where smallImageId = &#63;.
5047             *
5048             * @param smallImageId the small image ID
5049             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5050             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
5051             * @throws SystemException if a system exception occurred
5052             */
5053            public JournalArticle fetchBySmallImageId_Last(long smallImageId,
5054                    OrderByComparator orderByComparator) throws SystemException {
5055                    int count = countBySmallImageId(smallImageId);
5056    
5057                    List<JournalArticle> list = findBySmallImageId(smallImageId, count - 1,
5058                                    count, orderByComparator);
5059    
5060                    if (!list.isEmpty()) {
5061                            return list.get(0);
5062                    }
5063    
5064                    return null;
5065            }
5066    
5067            /**
5068             * Returns the journal articles before and after the current journal article in the ordered set where smallImageId = &#63;.
5069             *
5070             * @param id the primary key of the current journal article
5071             * @param smallImageId the small image ID
5072             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5073             * @return the previous, current, and next journal article
5074             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
5075             * @throws SystemException if a system exception occurred
5076             */
5077            public JournalArticle[] findBySmallImageId_PrevAndNext(long id,
5078                    long smallImageId, OrderByComparator orderByComparator)
5079                    throws NoSuchArticleException, SystemException {
5080                    JournalArticle journalArticle = findByPrimaryKey(id);
5081    
5082                    Session session = null;
5083    
5084                    try {
5085                            session = openSession();
5086    
5087                            JournalArticle[] array = new JournalArticleImpl[3];
5088    
5089                            array[0] = getBySmallImageId_PrevAndNext(session, journalArticle,
5090                                            smallImageId, orderByComparator, true);
5091    
5092                            array[1] = journalArticle;
5093    
5094                            array[2] = getBySmallImageId_PrevAndNext(session, journalArticle,
5095                                            smallImageId, orderByComparator, false);
5096    
5097                            return array;
5098                    }
5099                    catch (Exception e) {
5100                            throw processException(e);
5101                    }
5102                    finally {
5103                            closeSession(session);
5104                    }
5105            }
5106    
5107            protected JournalArticle getBySmallImageId_PrevAndNext(Session session,
5108                    JournalArticle journalArticle, long smallImageId,
5109                    OrderByComparator orderByComparator, boolean previous) {
5110                    StringBundler query = null;
5111    
5112                    if (orderByComparator != null) {
5113                            query = new StringBundler(6 +
5114                                            (orderByComparator.getOrderByFields().length * 6));
5115                    }
5116                    else {
5117                            query = new StringBundler(3);
5118                    }
5119    
5120                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5121    
5122                    query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
5123    
5124                    if (orderByComparator != null) {
5125                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5126    
5127                            if (orderByConditionFields.length > 0) {
5128                                    query.append(WHERE_AND);
5129                            }
5130    
5131                            for (int i = 0; i < orderByConditionFields.length; i++) {
5132                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5133                                    query.append(orderByConditionFields[i]);
5134    
5135                                    if ((i + 1) < orderByConditionFields.length) {
5136                                            if (orderByComparator.isAscending() ^ previous) {
5137                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5138                                            }
5139                                            else {
5140                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5141                                            }
5142                                    }
5143                                    else {
5144                                            if (orderByComparator.isAscending() ^ previous) {
5145                                                    query.append(WHERE_GREATER_THAN);
5146                                            }
5147                                            else {
5148                                                    query.append(WHERE_LESSER_THAN);
5149                                            }
5150                                    }
5151                            }
5152    
5153                            query.append(ORDER_BY_CLAUSE);
5154    
5155                            String[] orderByFields = orderByComparator.getOrderByFields();
5156    
5157                            for (int i = 0; i < orderByFields.length; i++) {
5158                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5159                                    query.append(orderByFields[i]);
5160    
5161                                    if ((i + 1) < orderByFields.length) {
5162                                            if (orderByComparator.isAscending() ^ previous) {
5163                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5164                                            }
5165                                            else {
5166                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5167                                            }
5168                                    }
5169                                    else {
5170                                            if (orderByComparator.isAscending() ^ previous) {
5171                                                    query.append(ORDER_BY_ASC);
5172                                            }
5173                                            else {
5174                                                    query.append(ORDER_BY_DESC);
5175                                            }
5176                                    }
5177                            }
5178                    }
5179                    else {
5180                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5181                    }
5182    
5183                    String sql = query.toString();
5184    
5185                    Query q = session.createQuery(sql);
5186    
5187                    q.setFirstResult(0);
5188                    q.setMaxResults(2);
5189    
5190                    QueryPos qPos = QueryPos.getInstance(q);
5191    
5192                    qPos.add(smallImageId);
5193    
5194                    if (orderByComparator != null) {
5195                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
5196    
5197                            for (Object value : values) {
5198                                    qPos.add(value);
5199                            }
5200                    }
5201    
5202                    List<JournalArticle> list = q.list();
5203    
5204                    if (list.size() == 2) {
5205                            return list.get(1);
5206                    }
5207                    else {
5208                            return null;
5209                    }
5210            }
5211    
5212            /**
5213             * Removes all the journal articles where smallImageId = &#63; from the database.
5214             *
5215             * @param smallImageId the small image ID
5216             * @throws SystemException if a system exception occurred
5217             */
5218            public void removeBySmallImageId(long smallImageId)
5219                    throws SystemException {
5220                    for (JournalArticle journalArticle : findBySmallImageId(smallImageId,
5221                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5222                            remove(journalArticle);
5223                    }
5224            }
5225    
5226            /**
5227             * Returns the number of journal articles where smallImageId = &#63;.
5228             *
5229             * @param smallImageId the small image ID
5230             * @return the number of matching journal articles
5231             * @throws SystemException if a system exception occurred
5232             */
5233            public int countBySmallImageId(long smallImageId) throws SystemException {
5234                    FinderPath finderPath = FINDER_PATH_COUNT_BY_SMALLIMAGEID;
5235    
5236                    Object[] finderArgs = new Object[] { smallImageId };
5237    
5238                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5239                                    this);
5240    
5241                    if (count == null) {
5242                            StringBundler query = new StringBundler(2);
5243    
5244                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
5245    
5246                            query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
5247    
5248                            String sql = query.toString();
5249    
5250                            Session session = null;
5251    
5252                            try {
5253                                    session = openSession();
5254    
5255                                    Query q = session.createQuery(sql);
5256    
5257                                    QueryPos qPos = QueryPos.getInstance(q);
5258    
5259                                    qPos.add(smallImageId);
5260    
5261                                    count = (Long)q.uniqueResult();
5262    
5263                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5264                            }
5265                            catch (Exception e) {
5266                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5267    
5268                                    throw processException(e);
5269                            }
5270                            finally {
5271                                    closeSession(session);
5272                            }
5273                    }
5274    
5275                    return count.intValue();
5276            }
5277    
5278            private static final String _FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2 = "journalArticle.smallImageId = ?";
5279            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5280                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5281                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5282                            "findByR_ST",
5283                            new String[] {
5284                                    Long.class.getName(), Integer.class.getName(),
5285                                    
5286                            Integer.class.getName(), Integer.class.getName(),
5287                                    OrderByComparator.class.getName()
5288                            });
5289            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5290                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5291                            JournalArticleImpl.class,
5292                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_ST",
5293                            new String[] { Long.class.getName(), Integer.class.getName() },
5294                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
5295                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
5296                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
5297                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
5298            public static final FinderPath FINDER_PATH_COUNT_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5299                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
5300                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_ST",
5301                            new String[] { Long.class.getName(), Integer.class.getName() });
5302    
5303            /**
5304             * Returns all the journal articles where resourcePrimKey = &#63; and status = &#63;.
5305             *
5306             * @param resourcePrimKey the resource prim key
5307             * @param status the status
5308             * @return the matching journal articles
5309             * @throws SystemException if a system exception occurred
5310             */
5311            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status)
5312                    throws SystemException {
5313                    return findByR_ST(resourcePrimKey, status, QueryUtil.ALL_POS,
5314                            QueryUtil.ALL_POS, null);
5315            }
5316    
5317            /**
5318             * Returns a range of all the journal articles where resourcePrimKey = &#63; and status = &#63;.
5319             *
5320             * <p>
5321             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5322             * </p>
5323             *
5324             * @param resourcePrimKey the resource prim key
5325             * @param status the status
5326             * @param start the lower bound of the range of journal articles
5327             * @param end the upper bound of the range of journal articles (not inclusive)
5328             * @return the range of matching journal articles
5329             * @throws SystemException if a system exception occurred
5330             */
5331            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status,
5332                    int start, int end) throws SystemException {
5333                    return findByR_ST(resourcePrimKey, status, start, end, null);
5334            }
5335    
5336            /**
5337             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and status = &#63;.
5338             *
5339             * <p>
5340             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5341             * </p>
5342             *
5343             * @param resourcePrimKey the resource prim key
5344             * @param status the status
5345             * @param start the lower bound of the range of journal articles
5346             * @param end the upper bound of the range of journal articles (not inclusive)
5347             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5348             * @return the ordered range of matching journal articles
5349             * @throws SystemException if a system exception occurred
5350             */
5351            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status,
5352                    int start, int end, OrderByComparator orderByComparator)
5353                    throws SystemException {
5354                    boolean pagination = true;
5355                    FinderPath finderPath = null;
5356                    Object[] finderArgs = null;
5357    
5358                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5359                                    (orderByComparator == null)) {
5360                            pagination = false;
5361                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST;
5362                            finderArgs = new Object[] { resourcePrimKey, status };
5363                    }
5364                    else {
5365                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST;
5366                            finderArgs = new Object[] {
5367                                            resourcePrimKey, status,
5368                                            
5369                                            start, end, orderByComparator
5370                                    };
5371                    }
5372    
5373                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
5374                                    finderArgs, this);
5375    
5376                    if ((list != null) && !list.isEmpty()) {
5377                            for (JournalArticle journalArticle : list) {
5378                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
5379                                                    (status != journalArticle.getStatus())) {
5380                                            list = null;
5381    
5382                                            break;
5383                                    }
5384                            }
5385                    }
5386    
5387                    if (list == null) {
5388                            StringBundler query = null;
5389    
5390                            if (orderByComparator != null) {
5391                                    query = new StringBundler(4 +
5392                                                    (orderByComparator.getOrderByFields().length * 3));
5393                            }
5394                            else {
5395                                    query = new StringBundler(4);
5396                            }
5397    
5398                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5399    
5400                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
5401    
5402                            query.append(_FINDER_COLUMN_R_ST_STATUS_2);
5403    
5404                            if (orderByComparator != null) {
5405                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5406                                            orderByComparator);
5407                            }
5408                            else
5409                             if (pagination) {
5410                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5411                            }
5412    
5413                            String sql = query.toString();
5414    
5415                            Session session = null;
5416    
5417                            try {
5418                                    session = openSession();
5419    
5420                                    Query q = session.createQuery(sql);
5421    
5422                                    QueryPos qPos = QueryPos.getInstance(q);
5423    
5424                                    qPos.add(resourcePrimKey);
5425    
5426                                    qPos.add(status);
5427    
5428                                    if (!pagination) {
5429                                            list = (List<JournalArticle>)QueryUtil.list(q,
5430                                                            getDialect(), start, end, false);
5431    
5432                                            Collections.sort(list);
5433    
5434                                            list = new UnmodifiableList<JournalArticle>(list);
5435                                    }
5436                                    else {
5437                                            list = (List<JournalArticle>)QueryUtil.list(q,
5438                                                            getDialect(), start, end);
5439                                    }
5440    
5441                                    cacheResult(list);
5442    
5443                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5444                            }
5445                            catch (Exception e) {
5446                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5447    
5448                                    throw processException(e);
5449                            }
5450                            finally {
5451                                    closeSession(session);
5452                            }
5453                    }
5454    
5455                    return list;
5456            }
5457    
5458            /**
5459             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
5460             *
5461             * @param resourcePrimKey the resource prim key
5462             * @param status the status
5463             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5464             * @return the first matching journal article
5465             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5466             * @throws SystemException if a system exception occurred
5467             */
5468            public JournalArticle findByR_ST_First(long resourcePrimKey, int status,
5469                    OrderByComparator orderByComparator)
5470                    throws NoSuchArticleException, SystemException {
5471                    JournalArticle journalArticle = fetchByR_ST_First(resourcePrimKey,
5472                                    status, orderByComparator);
5473    
5474                    if (journalArticle != null) {
5475                            return journalArticle;
5476                    }
5477    
5478                    StringBundler msg = new StringBundler(6);
5479    
5480                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5481    
5482                    msg.append("resourcePrimKey=");
5483                    msg.append(resourcePrimKey);
5484    
5485                    msg.append(", status=");
5486                    msg.append(status);
5487    
5488                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5489    
5490                    throw new NoSuchArticleException(msg.toString());
5491            }
5492    
5493            /**
5494             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
5495             *
5496             * @param resourcePrimKey the resource prim key
5497             * @param status the status
5498             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5499             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
5500             * @throws SystemException if a system exception occurred
5501             */
5502            public JournalArticle fetchByR_ST_First(long resourcePrimKey, int status,
5503                    OrderByComparator orderByComparator) throws SystemException {
5504                    List<JournalArticle> list = findByR_ST(resourcePrimKey, status, 0, 1,
5505                                    orderByComparator);
5506    
5507                    if (!list.isEmpty()) {
5508                            return list.get(0);
5509                    }
5510    
5511                    return null;
5512            }
5513    
5514            /**
5515             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
5516             *
5517             * @param resourcePrimKey the resource prim key
5518             * @param status the status
5519             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5520             * @return the last matching journal article
5521             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5522             * @throws SystemException if a system exception occurred
5523             */
5524            public JournalArticle findByR_ST_Last(long resourcePrimKey, int status,
5525                    OrderByComparator orderByComparator)
5526                    throws NoSuchArticleException, SystemException {
5527                    JournalArticle journalArticle = fetchByR_ST_Last(resourcePrimKey,
5528                                    status, orderByComparator);
5529    
5530                    if (journalArticle != null) {
5531                            return journalArticle;
5532                    }
5533    
5534                    StringBundler msg = new StringBundler(6);
5535    
5536                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5537    
5538                    msg.append("resourcePrimKey=");
5539                    msg.append(resourcePrimKey);
5540    
5541                    msg.append(", status=");
5542                    msg.append(status);
5543    
5544                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5545    
5546                    throw new NoSuchArticleException(msg.toString());
5547            }
5548    
5549            /**
5550             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
5551             *
5552             * @param resourcePrimKey the resource prim key
5553             * @param status the status
5554             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5555             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
5556             * @throws SystemException if a system exception occurred
5557             */
5558            public JournalArticle fetchByR_ST_Last(long resourcePrimKey, int status,
5559                    OrderByComparator orderByComparator) throws SystemException {
5560                    int count = countByR_ST(resourcePrimKey, status);
5561    
5562                    List<JournalArticle> list = findByR_ST(resourcePrimKey, status,
5563                                    count - 1, count, orderByComparator);
5564    
5565                    if (!list.isEmpty()) {
5566                            return list.get(0);
5567                    }
5568    
5569                    return null;
5570            }
5571    
5572            /**
5573             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
5574             *
5575             * @param id the primary key of the current journal article
5576             * @param resourcePrimKey the resource prim key
5577             * @param status the status
5578             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5579             * @return the previous, current, and next journal article
5580             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
5581             * @throws SystemException if a system exception occurred
5582             */
5583            public JournalArticle[] findByR_ST_PrevAndNext(long id,
5584                    long resourcePrimKey, int status, OrderByComparator orderByComparator)
5585                    throws NoSuchArticleException, SystemException {
5586                    JournalArticle journalArticle = findByPrimaryKey(id);
5587    
5588                    Session session = null;
5589    
5590                    try {
5591                            session = openSession();
5592    
5593                            JournalArticle[] array = new JournalArticleImpl[3];
5594    
5595                            array[0] = getByR_ST_PrevAndNext(session, journalArticle,
5596                                            resourcePrimKey, status, orderByComparator, true);
5597    
5598                            array[1] = journalArticle;
5599    
5600                            array[2] = getByR_ST_PrevAndNext(session, journalArticle,
5601                                            resourcePrimKey, status, orderByComparator, false);
5602    
5603                            return array;
5604                    }
5605                    catch (Exception e) {
5606                            throw processException(e);
5607                    }
5608                    finally {
5609                            closeSession(session);
5610                    }
5611            }
5612    
5613            protected JournalArticle getByR_ST_PrevAndNext(Session session,
5614                    JournalArticle journalArticle, long resourcePrimKey, int status,
5615                    OrderByComparator orderByComparator, boolean previous) {
5616                    StringBundler query = null;
5617    
5618                    if (orderByComparator != null) {
5619                            query = new StringBundler(6 +
5620                                            (orderByComparator.getOrderByFields().length * 6));
5621                    }
5622                    else {
5623                            query = new StringBundler(3);
5624                    }
5625    
5626                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5627    
5628                    query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
5629    
5630                    query.append(_FINDER_COLUMN_R_ST_STATUS_2);
5631    
5632                    if (orderByComparator != null) {
5633                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5634    
5635                            if (orderByConditionFields.length > 0) {
5636                                    query.append(WHERE_AND);
5637                            }
5638    
5639                            for (int i = 0; i < orderByConditionFields.length; i++) {
5640                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5641                                    query.append(orderByConditionFields[i]);
5642    
5643                                    if ((i + 1) < orderByConditionFields.length) {
5644                                            if (orderByComparator.isAscending() ^ previous) {
5645                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5646                                            }
5647                                            else {
5648                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5649                                            }
5650                                    }
5651                                    else {
5652                                            if (orderByComparator.isAscending() ^ previous) {
5653                                                    query.append(WHERE_GREATER_THAN);
5654                                            }
5655                                            else {
5656                                                    query.append(WHERE_LESSER_THAN);
5657                                            }
5658                                    }
5659                            }
5660    
5661                            query.append(ORDER_BY_CLAUSE);
5662    
5663                            String[] orderByFields = orderByComparator.getOrderByFields();
5664    
5665                            for (int i = 0; i < orderByFields.length; i++) {
5666                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5667                                    query.append(orderByFields[i]);
5668    
5669                                    if ((i + 1) < orderByFields.length) {
5670                                            if (orderByComparator.isAscending() ^ previous) {
5671                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5672                                            }
5673                                            else {
5674                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5675                                            }
5676                                    }
5677                                    else {
5678                                            if (orderByComparator.isAscending() ^ previous) {
5679                                                    query.append(ORDER_BY_ASC);
5680                                            }
5681                                            else {
5682                                                    query.append(ORDER_BY_DESC);
5683                                            }
5684                                    }
5685                            }
5686                    }
5687                    else {
5688                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5689                    }
5690    
5691                    String sql = query.toString();
5692    
5693                    Query q = session.createQuery(sql);
5694    
5695                    q.setFirstResult(0);
5696                    q.setMaxResults(2);
5697    
5698                    QueryPos qPos = QueryPos.getInstance(q);
5699    
5700                    qPos.add(resourcePrimKey);
5701    
5702                    qPos.add(status);
5703    
5704                    if (orderByComparator != null) {
5705                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
5706    
5707                            for (Object value : values) {
5708                                    qPos.add(value);
5709                            }
5710                    }
5711    
5712                    List<JournalArticle> list = q.list();
5713    
5714                    if (list.size() == 2) {
5715                            return list.get(1);
5716                    }
5717                    else {
5718                            return null;
5719                    }
5720            }
5721    
5722            /**
5723             * Removes all the journal articles where resourcePrimKey = &#63; and status = &#63; from the database.
5724             *
5725             * @param resourcePrimKey the resource prim key
5726             * @param status the status
5727             * @throws SystemException if a system exception occurred
5728             */
5729            public void removeByR_ST(long resourcePrimKey, int status)
5730                    throws SystemException {
5731                    for (JournalArticle journalArticle : findByR_ST(resourcePrimKey,
5732                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5733                            remove(journalArticle);
5734                    }
5735            }
5736    
5737            /**
5738             * Returns the number of journal articles where resourcePrimKey = &#63; and status = &#63;.
5739             *
5740             * @param resourcePrimKey the resource prim key
5741             * @param status the status
5742             * @return the number of matching journal articles
5743             * @throws SystemException if a system exception occurred
5744             */
5745            public int countByR_ST(long resourcePrimKey, int status)
5746                    throws SystemException {
5747                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_ST;
5748    
5749                    Object[] finderArgs = new Object[] { resourcePrimKey, status };
5750    
5751                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5752                                    this);
5753    
5754                    if (count == null) {
5755                            StringBundler query = new StringBundler(3);
5756    
5757                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
5758    
5759                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
5760    
5761                            query.append(_FINDER_COLUMN_R_ST_STATUS_2);
5762    
5763                            String sql = query.toString();
5764    
5765                            Session session = null;
5766    
5767                            try {
5768                                    session = openSession();
5769    
5770                                    Query q = session.createQuery(sql);
5771    
5772                                    QueryPos qPos = QueryPos.getInstance(q);
5773    
5774                                    qPos.add(resourcePrimKey);
5775    
5776                                    qPos.add(status);
5777    
5778                                    count = (Long)q.uniqueResult();
5779    
5780                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5781                            }
5782                            catch (Exception e) {
5783                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5784    
5785                                    throw processException(e);
5786                            }
5787                            finally {
5788                                    closeSession(session);
5789                            }
5790                    }
5791    
5792                    return count.intValue();
5793            }
5794    
5795            private static final String _FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2 = "journalArticle.resourcePrimKey = ? AND ";
5796            private static final String _FINDER_COLUMN_R_ST_STATUS_2 = "journalArticle.status = ?";
5797            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5798                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5799                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5800                            "findByG_U",
5801                            new String[] {
5802                                    Long.class.getName(), Long.class.getName(),
5803                                    
5804                            Integer.class.getName(), Integer.class.getName(),
5805                                    OrderByComparator.class.getName()
5806                            });
5807            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5808                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5809                            JournalArticleImpl.class,
5810                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U",
5811                            new String[] { Long.class.getName(), Long.class.getName() },
5812                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
5813                            JournalArticleModelImpl.USERID_COLUMN_BITMASK |
5814                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
5815                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
5816            public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5817                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
5818                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U",
5819                            new String[] { Long.class.getName(), Long.class.getName() });
5820    
5821            /**
5822             * Returns all the journal articles where groupId = &#63; and userId = &#63;.
5823             *
5824             * @param groupId the group ID
5825             * @param userId the user ID
5826             * @return the matching journal articles
5827             * @throws SystemException if a system exception occurred
5828             */
5829            public List<JournalArticle> findByG_U(long groupId, long userId)
5830                    throws SystemException {
5831                    return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
5832                            null);
5833            }
5834    
5835            /**
5836             * Returns a range of all the journal articles where groupId = &#63; and userId = &#63;.
5837             *
5838             * <p>
5839             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5840             * </p>
5841             *
5842             * @param groupId the group ID
5843             * @param userId the user ID
5844             * @param start the lower bound of the range of journal articles
5845             * @param end the upper bound of the range of journal articles (not inclusive)
5846             * @return the range of matching journal articles
5847             * @throws SystemException if a system exception occurred
5848             */
5849            public List<JournalArticle> findByG_U(long groupId, long userId, int start,
5850                    int end) throws SystemException {
5851                    return findByG_U(groupId, userId, start, end, null);
5852            }
5853    
5854            /**
5855             * Returns an ordered range of all the journal articles where groupId = &#63; and userId = &#63;.
5856             *
5857             * <p>
5858             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5859             * </p>
5860             *
5861             * @param groupId the group ID
5862             * @param userId the user ID
5863             * @param start the lower bound of the range of journal articles
5864             * @param end the upper bound of the range of journal articles (not inclusive)
5865             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5866             * @return the ordered range of matching journal articles
5867             * @throws SystemException if a system exception occurred
5868             */
5869            public List<JournalArticle> findByG_U(long groupId, long userId, int start,
5870                    int end, OrderByComparator orderByComparator) throws SystemException {
5871                    boolean pagination = true;
5872                    FinderPath finderPath = null;
5873                    Object[] finderArgs = null;
5874    
5875                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5876                                    (orderByComparator == null)) {
5877                            pagination = false;
5878                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U;
5879                            finderArgs = new Object[] { groupId, userId };
5880                    }
5881                    else {
5882                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U;
5883                            finderArgs = new Object[] {
5884                                            groupId, userId,
5885                                            
5886                                            start, end, orderByComparator
5887                                    };
5888                    }
5889    
5890                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
5891                                    finderArgs, this);
5892    
5893                    if ((list != null) && !list.isEmpty()) {
5894                            for (JournalArticle journalArticle : list) {
5895                                    if ((groupId != journalArticle.getGroupId()) ||
5896                                                    (userId != journalArticle.getUserId())) {
5897                                            list = null;
5898    
5899                                            break;
5900                                    }
5901                            }
5902                    }
5903    
5904                    if (list == null) {
5905                            StringBundler query = null;
5906    
5907                            if (orderByComparator != null) {
5908                                    query = new StringBundler(4 +
5909                                                    (orderByComparator.getOrderByFields().length * 3));
5910                            }
5911                            else {
5912                                    query = new StringBundler(4);
5913                            }
5914    
5915                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5916    
5917                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
5918    
5919                            query.append(_FINDER_COLUMN_G_U_USERID_2);
5920    
5921                            if (orderByComparator != null) {
5922                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5923                                            orderByComparator);
5924                            }
5925                            else
5926                             if (pagination) {
5927                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5928                            }
5929    
5930                            String sql = query.toString();
5931    
5932                            Session session = null;
5933    
5934                            try {
5935                                    session = openSession();
5936    
5937                                    Query q = session.createQuery(sql);
5938    
5939                                    QueryPos qPos = QueryPos.getInstance(q);
5940    
5941                                    qPos.add(groupId);
5942    
5943                                    qPos.add(userId);
5944    
5945                                    if (!pagination) {
5946                                            list = (List<JournalArticle>)QueryUtil.list(q,
5947                                                            getDialect(), start, end, false);
5948    
5949                                            Collections.sort(list);
5950    
5951                                            list = new UnmodifiableList<JournalArticle>(list);
5952                                    }
5953                                    else {
5954                                            list = (List<JournalArticle>)QueryUtil.list(q,
5955                                                            getDialect(), start, end);
5956                                    }
5957    
5958                                    cacheResult(list);
5959    
5960                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5961                            }
5962                            catch (Exception e) {
5963                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5964    
5965                                    throw processException(e);
5966                            }
5967                            finally {
5968                                    closeSession(session);
5969                            }
5970                    }
5971    
5972                    return list;
5973            }
5974    
5975            /**
5976             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63;.
5977             *
5978             * @param groupId the group ID
5979             * @param userId the user ID
5980             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5981             * @return the first matching journal article
5982             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5983             * @throws SystemException if a system exception occurred
5984             */
5985            public JournalArticle findByG_U_First(long groupId, long userId,
5986                    OrderByComparator orderByComparator)
5987                    throws NoSuchArticleException, SystemException {
5988                    JournalArticle journalArticle = fetchByG_U_First(groupId, userId,
5989                                    orderByComparator);
5990    
5991                    if (journalArticle != null) {
5992                            return journalArticle;
5993                    }
5994    
5995                    StringBundler msg = new StringBundler(6);
5996    
5997                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5998    
5999                    msg.append("groupId=");
6000                    msg.append(groupId);
6001    
6002                    msg.append(", userId=");
6003                    msg.append(userId);
6004    
6005                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6006    
6007                    throw new NoSuchArticleException(msg.toString());
6008            }
6009    
6010            /**
6011             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63;.
6012             *
6013             * @param groupId the group ID
6014             * @param userId the user ID
6015             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6016             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
6017             * @throws SystemException if a system exception occurred
6018             */
6019            public JournalArticle fetchByG_U_First(long groupId, long userId,
6020                    OrderByComparator orderByComparator) throws SystemException {
6021                    List<JournalArticle> list = findByG_U(groupId, userId, 0, 1,
6022                                    orderByComparator);
6023    
6024                    if (!list.isEmpty()) {
6025                            return list.get(0);
6026                    }
6027    
6028                    return null;
6029            }
6030    
6031            /**
6032             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63;.
6033             *
6034             * @param groupId the group ID
6035             * @param userId the user ID
6036             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6037             * @return the last matching journal article
6038             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6039             * @throws SystemException if a system exception occurred
6040             */
6041            public JournalArticle findByG_U_Last(long groupId, long userId,
6042                    OrderByComparator orderByComparator)
6043                    throws NoSuchArticleException, SystemException {
6044                    JournalArticle journalArticle = fetchByG_U_Last(groupId, userId,
6045                                    orderByComparator);
6046    
6047                    if (journalArticle != null) {
6048                            return journalArticle;
6049                    }
6050    
6051                    StringBundler msg = new StringBundler(6);
6052    
6053                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6054    
6055                    msg.append("groupId=");
6056                    msg.append(groupId);
6057    
6058                    msg.append(", userId=");
6059                    msg.append(userId);
6060    
6061                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6062    
6063                    throw new NoSuchArticleException(msg.toString());
6064            }
6065    
6066            /**
6067             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63;.
6068             *
6069             * @param groupId the group ID
6070             * @param userId the user ID
6071             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6072             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
6073             * @throws SystemException if a system exception occurred
6074             */
6075            public JournalArticle fetchByG_U_Last(long groupId, long userId,
6076                    OrderByComparator orderByComparator) throws SystemException {
6077                    int count = countByG_U(groupId, userId);
6078    
6079                    List<JournalArticle> list = findByG_U(groupId, userId, count - 1,
6080                                    count, orderByComparator);
6081    
6082                    if (!list.isEmpty()) {
6083                            return list.get(0);
6084                    }
6085    
6086                    return null;
6087            }
6088    
6089            /**
6090             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and userId = &#63;.
6091             *
6092             * @param id the primary key of the current journal article
6093             * @param groupId the group ID
6094             * @param userId the user ID
6095             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6096             * @return the previous, current, and next journal article
6097             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6098             * @throws SystemException if a system exception occurred
6099             */
6100            public JournalArticle[] findByG_U_PrevAndNext(long id, long groupId,
6101                    long userId, OrderByComparator orderByComparator)
6102                    throws NoSuchArticleException, SystemException {
6103                    JournalArticle journalArticle = findByPrimaryKey(id);
6104    
6105                    Session session = null;
6106    
6107                    try {
6108                            session = openSession();
6109    
6110                            JournalArticle[] array = new JournalArticleImpl[3];
6111    
6112                            array[0] = getByG_U_PrevAndNext(session, journalArticle, groupId,
6113                                            userId, orderByComparator, true);
6114    
6115                            array[1] = journalArticle;
6116    
6117                            array[2] = getByG_U_PrevAndNext(session, journalArticle, groupId,
6118                                            userId, orderByComparator, false);
6119    
6120                            return array;
6121                    }
6122                    catch (Exception e) {
6123                            throw processException(e);
6124                    }
6125                    finally {
6126                            closeSession(session);
6127                    }
6128            }
6129    
6130            protected JournalArticle getByG_U_PrevAndNext(Session session,
6131                    JournalArticle journalArticle, long groupId, long userId,
6132                    OrderByComparator orderByComparator, boolean previous) {
6133                    StringBundler query = null;
6134    
6135                    if (orderByComparator != null) {
6136                            query = new StringBundler(6 +
6137                                            (orderByComparator.getOrderByFields().length * 6));
6138                    }
6139                    else {
6140                            query = new StringBundler(3);
6141                    }
6142    
6143                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6144    
6145                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
6146    
6147                    query.append(_FINDER_COLUMN_G_U_USERID_2);
6148    
6149                    if (orderByComparator != null) {
6150                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6151    
6152                            if (orderByConditionFields.length > 0) {
6153                                    query.append(WHERE_AND);
6154                            }
6155    
6156                            for (int i = 0; i < orderByConditionFields.length; i++) {
6157                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6158                                    query.append(orderByConditionFields[i]);
6159    
6160                                    if ((i + 1) < orderByConditionFields.length) {
6161                                            if (orderByComparator.isAscending() ^ previous) {
6162                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6163                                            }
6164                                            else {
6165                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6166                                            }
6167                                    }
6168                                    else {
6169                                            if (orderByComparator.isAscending() ^ previous) {
6170                                                    query.append(WHERE_GREATER_THAN);
6171                                            }
6172                                            else {
6173                                                    query.append(WHERE_LESSER_THAN);
6174                                            }
6175                                    }
6176                            }
6177    
6178                            query.append(ORDER_BY_CLAUSE);
6179    
6180                            String[] orderByFields = orderByComparator.getOrderByFields();
6181    
6182                            for (int i = 0; i < orderByFields.length; i++) {
6183                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6184                                    query.append(orderByFields[i]);
6185    
6186                                    if ((i + 1) < orderByFields.length) {
6187                                            if (orderByComparator.isAscending() ^ previous) {
6188                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6189                                            }
6190                                            else {
6191                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6192                                            }
6193                                    }
6194                                    else {
6195                                            if (orderByComparator.isAscending() ^ previous) {
6196                                                    query.append(ORDER_BY_ASC);
6197                                            }
6198                                            else {
6199                                                    query.append(ORDER_BY_DESC);
6200                                            }
6201                                    }
6202                            }
6203                    }
6204                    else {
6205                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6206                    }
6207    
6208                    String sql = query.toString();
6209    
6210                    Query q = session.createQuery(sql);
6211    
6212                    q.setFirstResult(0);
6213                    q.setMaxResults(2);
6214    
6215                    QueryPos qPos = QueryPos.getInstance(q);
6216    
6217                    qPos.add(groupId);
6218    
6219                    qPos.add(userId);
6220    
6221                    if (orderByComparator != null) {
6222                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6223    
6224                            for (Object value : values) {
6225                                    qPos.add(value);
6226                            }
6227                    }
6228    
6229                    List<JournalArticle> list = q.list();
6230    
6231                    if (list.size() == 2) {
6232                            return list.get(1);
6233                    }
6234                    else {
6235                            return null;
6236                    }
6237            }
6238    
6239            /**
6240             * Returns all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
6241             *
6242             * @param groupId the group ID
6243             * @param userId the user ID
6244             * @return the matching journal articles that the user has permission to view
6245             * @throws SystemException if a system exception occurred
6246             */
6247            public List<JournalArticle> filterFindByG_U(long groupId, long userId)
6248                    throws SystemException {
6249                    return filterFindByG_U(groupId, userId, QueryUtil.ALL_POS,
6250                            QueryUtil.ALL_POS, null);
6251            }
6252    
6253            /**
6254             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
6255             *
6256             * <p>
6257             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6258             * </p>
6259             *
6260             * @param groupId the group ID
6261             * @param userId the user ID
6262             * @param start the lower bound of the range of journal articles
6263             * @param end the upper bound of the range of journal articles (not inclusive)
6264             * @return the range of matching journal articles that the user has permission to view
6265             * @throws SystemException if a system exception occurred
6266             */
6267            public List<JournalArticle> filterFindByG_U(long groupId, long userId,
6268                    int start, int end) throws SystemException {
6269                    return filterFindByG_U(groupId, userId, start, end, null);
6270            }
6271    
6272            /**
6273             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and userId = &#63;.
6274             *
6275             * <p>
6276             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6277             * </p>
6278             *
6279             * @param groupId the group ID
6280             * @param userId the user ID
6281             * @param start the lower bound of the range of journal articles
6282             * @param end the upper bound of the range of journal articles (not inclusive)
6283             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6284             * @return the ordered range of matching journal articles that the user has permission to view
6285             * @throws SystemException if a system exception occurred
6286             */
6287            public List<JournalArticle> filterFindByG_U(long groupId, long userId,
6288                    int start, int end, OrderByComparator orderByComparator)
6289                    throws SystemException {
6290                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6291                            return findByG_U(groupId, userId, start, end, orderByComparator);
6292                    }
6293    
6294                    StringBundler query = null;
6295    
6296                    if (orderByComparator != null) {
6297                            query = new StringBundler(4 +
6298                                            (orderByComparator.getOrderByFields().length * 3));
6299                    }
6300                    else {
6301                            query = new StringBundler(4);
6302                    }
6303    
6304                    if (getDB().isSupportsInlineDistinct()) {
6305                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
6306                    }
6307                    else {
6308                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
6309                    }
6310    
6311                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
6312    
6313                    query.append(_FINDER_COLUMN_G_U_USERID_2);
6314    
6315                    if (!getDB().isSupportsInlineDistinct()) {
6316                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
6317                    }
6318    
6319                    if (orderByComparator != null) {
6320                            if (getDB().isSupportsInlineDistinct()) {
6321                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6322                                            orderByComparator);
6323                            }
6324                            else {
6325                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6326                                            orderByComparator);
6327                            }
6328                    }
6329                    else {
6330                            if (getDB().isSupportsInlineDistinct()) {
6331                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6332                            }
6333                            else {
6334                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
6335                            }
6336                    }
6337    
6338                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6339                                    JournalArticle.class.getName(),
6340                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6341    
6342                    Session session = null;
6343    
6344                    try {
6345                            session = openSession();
6346    
6347                            SQLQuery q = session.createSQLQuery(sql);
6348    
6349                            if (getDB().isSupportsInlineDistinct()) {
6350                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
6351                            }
6352                            else {
6353                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
6354                            }
6355    
6356                            QueryPos qPos = QueryPos.getInstance(q);
6357    
6358                            qPos.add(groupId);
6359    
6360                            qPos.add(userId);
6361    
6362                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
6363                                    end);
6364                    }
6365                    catch (Exception e) {
6366                            throw processException(e);
6367                    }
6368                    finally {
6369                            closeSession(session);
6370                    }
6371            }
6372    
6373            /**
6374             * 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;.
6375             *
6376             * @param id the primary key of the current journal article
6377             * @param groupId the group ID
6378             * @param userId the user ID
6379             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6380             * @return the previous, current, and next journal article
6381             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6382             * @throws SystemException if a system exception occurred
6383             */
6384            public JournalArticle[] filterFindByG_U_PrevAndNext(long id, long groupId,
6385                    long userId, OrderByComparator orderByComparator)
6386                    throws NoSuchArticleException, SystemException {
6387                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6388                            return findByG_U_PrevAndNext(id, groupId, userId, orderByComparator);
6389                    }
6390    
6391                    JournalArticle journalArticle = findByPrimaryKey(id);
6392    
6393                    Session session = null;
6394    
6395                    try {
6396                            session = openSession();
6397    
6398                            JournalArticle[] array = new JournalArticleImpl[3];
6399    
6400                            array[0] = filterGetByG_U_PrevAndNext(session, journalArticle,
6401                                            groupId, userId, orderByComparator, true);
6402    
6403                            array[1] = journalArticle;
6404    
6405                            array[2] = filterGetByG_U_PrevAndNext(session, journalArticle,
6406                                            groupId, userId, orderByComparator, false);
6407    
6408                            return array;
6409                    }
6410                    catch (Exception e) {
6411                            throw processException(e);
6412                    }
6413                    finally {
6414                            closeSession(session);
6415                    }
6416            }
6417    
6418            protected JournalArticle filterGetByG_U_PrevAndNext(Session session,
6419                    JournalArticle journalArticle, long groupId, long userId,
6420                    OrderByComparator orderByComparator, boolean previous) {
6421                    StringBundler query = null;
6422    
6423                    if (orderByComparator != null) {
6424                            query = new StringBundler(6 +
6425                                            (orderByComparator.getOrderByFields().length * 6));
6426                    }
6427                    else {
6428                            query = new StringBundler(3);
6429                    }
6430    
6431                    if (getDB().isSupportsInlineDistinct()) {
6432                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
6433                    }
6434                    else {
6435                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
6436                    }
6437    
6438                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
6439    
6440                    query.append(_FINDER_COLUMN_G_U_USERID_2);
6441    
6442                    if (!getDB().isSupportsInlineDistinct()) {
6443                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
6444                    }
6445    
6446                    if (orderByComparator != null) {
6447                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6448    
6449                            if (orderByConditionFields.length > 0) {
6450                                    query.append(WHERE_AND);
6451                            }
6452    
6453                            for (int i = 0; i < orderByConditionFields.length; i++) {
6454                                    if (getDB().isSupportsInlineDistinct()) {
6455                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6456                                    }
6457                                    else {
6458                                            query.append(_ORDER_BY_ENTITY_TABLE);
6459                                    }
6460    
6461                                    query.append(orderByConditionFields[i]);
6462    
6463                                    if ((i + 1) < orderByConditionFields.length) {
6464                                            if (orderByComparator.isAscending() ^ previous) {
6465                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6466                                            }
6467                                            else {
6468                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6469                                            }
6470                                    }
6471                                    else {
6472                                            if (orderByComparator.isAscending() ^ previous) {
6473                                                    query.append(WHERE_GREATER_THAN);
6474                                            }
6475                                            else {
6476                                                    query.append(WHERE_LESSER_THAN);
6477                                            }
6478                                    }
6479                            }
6480    
6481                            query.append(ORDER_BY_CLAUSE);
6482    
6483                            String[] orderByFields = orderByComparator.getOrderByFields();
6484    
6485                            for (int i = 0; i < orderByFields.length; i++) {
6486                                    if (getDB().isSupportsInlineDistinct()) {
6487                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6488                                    }
6489                                    else {
6490                                            query.append(_ORDER_BY_ENTITY_TABLE);
6491                                    }
6492    
6493                                    query.append(orderByFields[i]);
6494    
6495                                    if ((i + 1) < orderByFields.length) {
6496                                            if (orderByComparator.isAscending() ^ previous) {
6497                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6498                                            }
6499                                            else {
6500                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6501                                            }
6502                                    }
6503                                    else {
6504                                            if (orderByComparator.isAscending() ^ previous) {
6505                                                    query.append(ORDER_BY_ASC);
6506                                            }
6507                                            else {
6508                                                    query.append(ORDER_BY_DESC);
6509                                            }
6510                                    }
6511                            }
6512                    }
6513                    else {
6514                            if (getDB().isSupportsInlineDistinct()) {
6515                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6516                            }
6517                            else {
6518                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
6519                            }
6520                    }
6521    
6522                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6523                                    JournalArticle.class.getName(),
6524                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6525    
6526                    SQLQuery q = session.createSQLQuery(sql);
6527    
6528                    q.setFirstResult(0);
6529                    q.setMaxResults(2);
6530    
6531                    if (getDB().isSupportsInlineDistinct()) {
6532                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
6533                    }
6534                    else {
6535                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
6536                    }
6537    
6538                    QueryPos qPos = QueryPos.getInstance(q);
6539    
6540                    qPos.add(groupId);
6541    
6542                    qPos.add(userId);
6543    
6544                    if (orderByComparator != null) {
6545                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6546    
6547                            for (Object value : values) {
6548                                    qPos.add(value);
6549                            }
6550                    }
6551    
6552                    List<JournalArticle> list = q.list();
6553    
6554                    if (list.size() == 2) {
6555                            return list.get(1);
6556                    }
6557                    else {
6558                            return null;
6559                    }
6560            }
6561    
6562            /**
6563             * Removes all the journal articles where groupId = &#63; and userId = &#63; from the database.
6564             *
6565             * @param groupId the group ID
6566             * @param userId the user ID
6567             * @throws SystemException if a system exception occurred
6568             */
6569            public void removeByG_U(long groupId, long userId)
6570                    throws SystemException {
6571                    for (JournalArticle journalArticle : findByG_U(groupId, userId,
6572                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6573                            remove(journalArticle);
6574                    }
6575            }
6576    
6577            /**
6578             * Returns the number of journal articles where groupId = &#63; and userId = &#63;.
6579             *
6580             * @param groupId the group ID
6581             * @param userId the user ID
6582             * @return the number of matching journal articles
6583             * @throws SystemException if a system exception occurred
6584             */
6585            public int countByG_U(long groupId, long userId) throws SystemException {
6586                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U;
6587    
6588                    Object[] finderArgs = new Object[] { groupId, userId };
6589    
6590                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6591                                    this);
6592    
6593                    if (count == null) {
6594                            StringBundler query = new StringBundler(3);
6595    
6596                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
6597    
6598                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
6599    
6600                            query.append(_FINDER_COLUMN_G_U_USERID_2);
6601    
6602                            String sql = query.toString();
6603    
6604                            Session session = null;
6605    
6606                            try {
6607                                    session = openSession();
6608    
6609                                    Query q = session.createQuery(sql);
6610    
6611                                    QueryPos qPos = QueryPos.getInstance(q);
6612    
6613                                    qPos.add(groupId);
6614    
6615                                    qPos.add(userId);
6616    
6617                                    count = (Long)q.uniqueResult();
6618    
6619                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6620                            }
6621                            catch (Exception e) {
6622                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6623    
6624                                    throw processException(e);
6625                            }
6626                            finally {
6627                                    closeSession(session);
6628                            }
6629                    }
6630    
6631                    return count.intValue();
6632            }
6633    
6634            /**
6635             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
6636             *
6637             * @param groupId the group ID
6638             * @param userId the user ID
6639             * @return the number of matching journal articles that the user has permission to view
6640             * @throws SystemException if a system exception occurred
6641             */
6642            public int filterCountByG_U(long groupId, long userId)
6643                    throws SystemException {
6644                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6645                            return countByG_U(groupId, userId);
6646                    }
6647    
6648                    StringBundler query = new StringBundler(3);
6649    
6650                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
6651    
6652                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
6653    
6654                    query.append(_FINDER_COLUMN_G_U_USERID_2);
6655    
6656                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6657                                    JournalArticle.class.getName(),
6658                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6659    
6660                    Session session = null;
6661    
6662                    try {
6663                            session = openSession();
6664    
6665                            SQLQuery q = session.createSQLQuery(sql);
6666    
6667                            q.addScalar(COUNT_COLUMN_NAME,
6668                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
6669    
6670                            QueryPos qPos = QueryPos.getInstance(q);
6671    
6672                            qPos.add(groupId);
6673    
6674                            qPos.add(userId);
6675    
6676                            Long count = (Long)q.uniqueResult();
6677    
6678                            return count.intValue();
6679                    }
6680                    catch (Exception e) {
6681                            throw processException(e);
6682                    }
6683                    finally {
6684                            closeSession(session);
6685                    }
6686            }
6687    
6688            private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "journalArticle.groupId = ? AND ";
6689            private static final String _FINDER_COLUMN_G_U_USERID_2 = "journalArticle.userId = ?";
6690            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6691                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
6692                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
6693                            "findByG_F",
6694                            new String[] {
6695                                    Long.class.getName(), Long.class.getName(),
6696                                    
6697                            Integer.class.getName(), Integer.class.getName(),
6698                                    OrderByComparator.class.getName()
6699                            });
6700            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6701                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
6702                            JournalArticleImpl.class,
6703                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F",
6704                            new String[] { Long.class.getName(), Long.class.getName() },
6705                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
6706                            JournalArticleModelImpl.FOLDERID_COLUMN_BITMASK |
6707                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
6708                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
6709            public static final FinderPath FINDER_PATH_COUNT_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6710                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
6711                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F",
6712                            new String[] { Long.class.getName(), Long.class.getName() });
6713            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6714                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
6715                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F",
6716                            new String[] { Long.class.getName(), Long.class.getName() });
6717    
6718            /**
6719             * Returns all the journal articles where groupId = &#63; and folderId = &#63;.
6720             *
6721             * @param groupId the group ID
6722             * @param folderId the folder ID
6723             * @return the matching journal articles
6724             * @throws SystemException if a system exception occurred
6725             */
6726            public List<JournalArticle> findByG_F(long groupId, long folderId)
6727                    throws SystemException {
6728                    return findByG_F(groupId, folderId, QueryUtil.ALL_POS,
6729                            QueryUtil.ALL_POS, null);
6730            }
6731    
6732            /**
6733             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63;.
6734             *
6735             * <p>
6736             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6737             * </p>
6738             *
6739             * @param groupId the group ID
6740             * @param folderId the folder ID
6741             * @param start the lower bound of the range of journal articles
6742             * @param end the upper bound of the range of journal articles (not inclusive)
6743             * @return the range of matching journal articles
6744             * @throws SystemException if a system exception occurred
6745             */
6746            public List<JournalArticle> findByG_F(long groupId, long folderId,
6747                    int start, int end) throws SystemException {
6748                    return findByG_F(groupId, folderId, start, end, null);
6749            }
6750    
6751            /**
6752             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63;.
6753             *
6754             * <p>
6755             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6756             * </p>
6757             *
6758             * @param groupId the group ID
6759             * @param folderId the folder ID
6760             * @param start the lower bound of the range of journal articles
6761             * @param end the upper bound of the range of journal articles (not inclusive)
6762             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6763             * @return the ordered range of matching journal articles
6764             * @throws SystemException if a system exception occurred
6765             */
6766            public List<JournalArticle> findByG_F(long groupId, long folderId,
6767                    int start, int end, OrderByComparator orderByComparator)
6768                    throws SystemException {
6769                    boolean pagination = true;
6770                    FinderPath finderPath = null;
6771                    Object[] finderArgs = null;
6772    
6773                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6774                                    (orderByComparator == null)) {
6775                            pagination = false;
6776                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F;
6777                            finderArgs = new Object[] { groupId, folderId };
6778                    }
6779                    else {
6780                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F;
6781                            finderArgs = new Object[] {
6782                                            groupId, folderId,
6783                                            
6784                                            start, end, orderByComparator
6785                                    };
6786                    }
6787    
6788                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
6789                                    finderArgs, this);
6790    
6791                    if ((list != null) && !list.isEmpty()) {
6792                            for (JournalArticle journalArticle : list) {
6793                                    if ((groupId != journalArticle.getGroupId()) ||
6794                                                    (folderId != journalArticle.getFolderId())) {
6795                                            list = null;
6796    
6797                                            break;
6798                                    }
6799                            }
6800                    }
6801    
6802                    if (list == null) {
6803                            StringBundler query = null;
6804    
6805                            if (orderByComparator != null) {
6806                                    query = new StringBundler(4 +
6807                                                    (orderByComparator.getOrderByFields().length * 3));
6808                            }
6809                            else {
6810                                    query = new StringBundler(4);
6811                            }
6812    
6813                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6814    
6815                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
6816    
6817                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
6818    
6819                            if (orderByComparator != null) {
6820                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6821                                            orderByComparator);
6822                            }
6823                            else
6824                             if (pagination) {
6825                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6826                            }
6827    
6828                            String sql = query.toString();
6829    
6830                            Session session = null;
6831    
6832                            try {
6833                                    session = openSession();
6834    
6835                                    Query q = session.createQuery(sql);
6836    
6837                                    QueryPos qPos = QueryPos.getInstance(q);
6838    
6839                                    qPos.add(groupId);
6840    
6841                                    qPos.add(folderId);
6842    
6843                                    if (!pagination) {
6844                                            list = (List<JournalArticle>)QueryUtil.list(q,
6845                                                            getDialect(), start, end, false);
6846    
6847                                            Collections.sort(list);
6848    
6849                                            list = new UnmodifiableList<JournalArticle>(list);
6850                                    }
6851                                    else {
6852                                            list = (List<JournalArticle>)QueryUtil.list(q,
6853                                                            getDialect(), start, end);
6854                                    }
6855    
6856                                    cacheResult(list);
6857    
6858                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6859                            }
6860                            catch (Exception e) {
6861                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6862    
6863                                    throw processException(e);
6864                            }
6865                            finally {
6866                                    closeSession(session);
6867                            }
6868                    }
6869    
6870                    return list;
6871            }
6872    
6873            /**
6874             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63;.
6875             *
6876             * @param groupId the group ID
6877             * @param folderId the folder ID
6878             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6879             * @return the first matching journal article
6880             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6881             * @throws SystemException if a system exception occurred
6882             */
6883            public JournalArticle findByG_F_First(long groupId, long folderId,
6884                    OrderByComparator orderByComparator)
6885                    throws NoSuchArticleException, SystemException {
6886                    JournalArticle journalArticle = fetchByG_F_First(groupId, folderId,
6887                                    orderByComparator);
6888    
6889                    if (journalArticle != null) {
6890                            return journalArticle;
6891                    }
6892    
6893                    StringBundler msg = new StringBundler(6);
6894    
6895                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6896    
6897                    msg.append("groupId=");
6898                    msg.append(groupId);
6899    
6900                    msg.append(", folderId=");
6901                    msg.append(folderId);
6902    
6903                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6904    
6905                    throw new NoSuchArticleException(msg.toString());
6906            }
6907    
6908            /**
6909             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63;.
6910             *
6911             * @param groupId the group ID
6912             * @param folderId the folder ID
6913             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6914             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
6915             * @throws SystemException if a system exception occurred
6916             */
6917            public JournalArticle fetchByG_F_First(long groupId, long folderId,
6918                    OrderByComparator orderByComparator) throws SystemException {
6919                    List<JournalArticle> list = findByG_F(groupId, folderId, 0, 1,
6920                                    orderByComparator);
6921    
6922                    if (!list.isEmpty()) {
6923                            return list.get(0);
6924                    }
6925    
6926                    return null;
6927            }
6928    
6929            /**
6930             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63;.
6931             *
6932             * @param groupId the group ID
6933             * @param folderId the folder ID
6934             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6935             * @return the last matching journal article
6936             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6937             * @throws SystemException if a system exception occurred
6938             */
6939            public JournalArticle findByG_F_Last(long groupId, long folderId,
6940                    OrderByComparator orderByComparator)
6941                    throws NoSuchArticleException, SystemException {
6942                    JournalArticle journalArticle = fetchByG_F_Last(groupId, folderId,
6943                                    orderByComparator);
6944    
6945                    if (journalArticle != null) {
6946                            return journalArticle;
6947                    }
6948    
6949                    StringBundler msg = new StringBundler(6);
6950    
6951                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6952    
6953                    msg.append("groupId=");
6954                    msg.append(groupId);
6955    
6956                    msg.append(", folderId=");
6957                    msg.append(folderId);
6958    
6959                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6960    
6961                    throw new NoSuchArticleException(msg.toString());
6962            }
6963    
6964            /**
6965             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63;.
6966             *
6967             * @param groupId the group ID
6968             * @param folderId the folder ID
6969             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6970             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
6971             * @throws SystemException if a system exception occurred
6972             */
6973            public JournalArticle fetchByG_F_Last(long groupId, long folderId,
6974                    OrderByComparator orderByComparator) throws SystemException {
6975                    int count = countByG_F(groupId, folderId);
6976    
6977                    List<JournalArticle> list = findByG_F(groupId, folderId, count - 1,
6978                                    count, orderByComparator);
6979    
6980                    if (!list.isEmpty()) {
6981                            return list.get(0);
6982                    }
6983    
6984                    return null;
6985            }
6986    
6987            /**
6988             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and folderId = &#63;.
6989             *
6990             * @param id the primary key of the current journal article
6991             * @param groupId the group ID
6992             * @param folderId the folder ID
6993             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6994             * @return the previous, current, and next journal article
6995             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6996             * @throws SystemException if a system exception occurred
6997             */
6998            public JournalArticle[] findByG_F_PrevAndNext(long id, long groupId,
6999                    long folderId, OrderByComparator orderByComparator)
7000                    throws NoSuchArticleException, SystemException {
7001                    JournalArticle journalArticle = findByPrimaryKey(id);
7002    
7003                    Session session = null;
7004    
7005                    try {
7006                            session = openSession();
7007    
7008                            JournalArticle[] array = new JournalArticleImpl[3];
7009    
7010                            array[0] = getByG_F_PrevAndNext(session, journalArticle, groupId,
7011                                            folderId, orderByComparator, true);
7012    
7013                            array[1] = journalArticle;
7014    
7015                            array[2] = getByG_F_PrevAndNext(session, journalArticle, groupId,
7016                                            folderId, orderByComparator, false);
7017    
7018                            return array;
7019                    }
7020                    catch (Exception e) {
7021                            throw processException(e);
7022                    }
7023                    finally {
7024                            closeSession(session);
7025                    }
7026            }
7027    
7028            protected JournalArticle getByG_F_PrevAndNext(Session session,
7029                    JournalArticle journalArticle, long groupId, long folderId,
7030                    OrderByComparator orderByComparator, boolean previous) {
7031                    StringBundler query = null;
7032    
7033                    if (orderByComparator != null) {
7034                            query = new StringBundler(6 +
7035                                            (orderByComparator.getOrderByFields().length * 6));
7036                    }
7037                    else {
7038                            query = new StringBundler(3);
7039                    }
7040    
7041                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7042    
7043                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
7044    
7045                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
7046    
7047                    if (orderByComparator != null) {
7048                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7049    
7050                            if (orderByConditionFields.length > 0) {
7051                                    query.append(WHERE_AND);
7052                            }
7053    
7054                            for (int i = 0; i < orderByConditionFields.length; i++) {
7055                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7056                                    query.append(orderByConditionFields[i]);
7057    
7058                                    if ((i + 1) < orderByConditionFields.length) {
7059                                            if (orderByComparator.isAscending() ^ previous) {
7060                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7061                                            }
7062                                            else {
7063                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7064                                            }
7065                                    }
7066                                    else {
7067                                            if (orderByComparator.isAscending() ^ previous) {
7068                                                    query.append(WHERE_GREATER_THAN);
7069                                            }
7070                                            else {
7071                                                    query.append(WHERE_LESSER_THAN);
7072                                            }
7073                                    }
7074                            }
7075    
7076                            query.append(ORDER_BY_CLAUSE);
7077    
7078                            String[] orderByFields = orderByComparator.getOrderByFields();
7079    
7080                            for (int i = 0; i < orderByFields.length; i++) {
7081                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7082                                    query.append(orderByFields[i]);
7083    
7084                                    if ((i + 1) < orderByFields.length) {
7085                                            if (orderByComparator.isAscending() ^ previous) {
7086                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7087                                            }
7088                                            else {
7089                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7090                                            }
7091                                    }
7092                                    else {
7093                                            if (orderByComparator.isAscending() ^ previous) {
7094                                                    query.append(ORDER_BY_ASC);
7095                                            }
7096                                            else {
7097                                                    query.append(ORDER_BY_DESC);
7098                                            }
7099                                    }
7100                            }
7101                    }
7102                    else {
7103                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7104                    }
7105    
7106                    String sql = query.toString();
7107    
7108                    Query q = session.createQuery(sql);
7109    
7110                    q.setFirstResult(0);
7111                    q.setMaxResults(2);
7112    
7113                    QueryPos qPos = QueryPos.getInstance(q);
7114    
7115                    qPos.add(groupId);
7116    
7117                    qPos.add(folderId);
7118    
7119                    if (orderByComparator != null) {
7120                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7121    
7122                            for (Object value : values) {
7123                                    qPos.add(value);
7124                            }
7125                    }
7126    
7127                    List<JournalArticle> list = q.list();
7128    
7129                    if (list.size() == 2) {
7130                            return list.get(1);
7131                    }
7132                    else {
7133                            return null;
7134                    }
7135            }
7136    
7137            /**
7138             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
7139             *
7140             * @param groupId the group ID
7141             * @param folderId the folder ID
7142             * @return the matching journal articles that the user has permission to view
7143             * @throws SystemException if a system exception occurred
7144             */
7145            public List<JournalArticle> filterFindByG_F(long groupId, long folderId)
7146                    throws SystemException {
7147                    return filterFindByG_F(groupId, folderId, QueryUtil.ALL_POS,
7148                            QueryUtil.ALL_POS, null);
7149            }
7150    
7151            /**
7152             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
7153             *
7154             * <p>
7155             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7156             * </p>
7157             *
7158             * @param groupId the group ID
7159             * @param folderId the folder ID
7160             * @param start the lower bound of the range of journal articles
7161             * @param end the upper bound of the range of journal articles (not inclusive)
7162             * @return the range of matching journal articles that the user has permission to view
7163             * @throws SystemException if a system exception occurred
7164             */
7165            public List<JournalArticle> filterFindByG_F(long groupId, long folderId,
7166                    int start, int end) throws SystemException {
7167                    return filterFindByG_F(groupId, folderId, start, end, null);
7168            }
7169    
7170            /**
7171             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and folderId = &#63;.
7172             *
7173             * <p>
7174             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7175             * </p>
7176             *
7177             * @param groupId the group ID
7178             * @param folderId the folder ID
7179             * @param start the lower bound of the range of journal articles
7180             * @param end the upper bound of the range of journal articles (not inclusive)
7181             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7182             * @return the ordered range of matching journal articles that the user has permission to view
7183             * @throws SystemException if a system exception occurred
7184             */
7185            public List<JournalArticle> filterFindByG_F(long groupId, long folderId,
7186                    int start, int end, OrderByComparator orderByComparator)
7187                    throws SystemException {
7188                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7189                            return findByG_F(groupId, folderId, start, end, orderByComparator);
7190                    }
7191    
7192                    StringBundler query = null;
7193    
7194                    if (orderByComparator != null) {
7195                            query = new StringBundler(4 +
7196                                            (orderByComparator.getOrderByFields().length * 3));
7197                    }
7198                    else {
7199                            query = new StringBundler(4);
7200                    }
7201    
7202                    if (getDB().isSupportsInlineDistinct()) {
7203                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7204                    }
7205                    else {
7206                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7207                    }
7208    
7209                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
7210    
7211                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
7212    
7213                    if (!getDB().isSupportsInlineDistinct()) {
7214                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7215                    }
7216    
7217                    if (orderByComparator != null) {
7218                            if (getDB().isSupportsInlineDistinct()) {
7219                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7220                                            orderByComparator);
7221                            }
7222                            else {
7223                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7224                                            orderByComparator);
7225                            }
7226                    }
7227                    else {
7228                            if (getDB().isSupportsInlineDistinct()) {
7229                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7230                            }
7231                            else {
7232                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7233                            }
7234                    }
7235    
7236                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7237                                    JournalArticle.class.getName(),
7238                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7239    
7240                    Session session = null;
7241    
7242                    try {
7243                            session = openSession();
7244    
7245                            SQLQuery q = session.createSQLQuery(sql);
7246    
7247                            if (getDB().isSupportsInlineDistinct()) {
7248                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7249                            }
7250                            else {
7251                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7252                            }
7253    
7254                            QueryPos qPos = QueryPos.getInstance(q);
7255    
7256                            qPos.add(groupId);
7257    
7258                            qPos.add(folderId);
7259    
7260                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
7261                                    end);
7262                    }
7263                    catch (Exception e) {
7264                            throw processException(e);
7265                    }
7266                    finally {
7267                            closeSession(session);
7268                    }
7269            }
7270    
7271            /**
7272             * 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;.
7273             *
7274             * @param id the primary key of the current journal article
7275             * @param groupId the group ID
7276             * @param folderId the folder ID
7277             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7278             * @return the previous, current, and next journal article
7279             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
7280             * @throws SystemException if a system exception occurred
7281             */
7282            public JournalArticle[] filterFindByG_F_PrevAndNext(long id, long groupId,
7283                    long folderId, OrderByComparator orderByComparator)
7284                    throws NoSuchArticleException, SystemException {
7285                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7286                            return findByG_F_PrevAndNext(id, groupId, folderId,
7287                                    orderByComparator);
7288                    }
7289    
7290                    JournalArticle journalArticle = findByPrimaryKey(id);
7291    
7292                    Session session = null;
7293    
7294                    try {
7295                            session = openSession();
7296    
7297                            JournalArticle[] array = new JournalArticleImpl[3];
7298    
7299                            array[0] = filterGetByG_F_PrevAndNext(session, journalArticle,
7300                                            groupId, folderId, orderByComparator, true);
7301    
7302                            array[1] = journalArticle;
7303    
7304                            array[2] = filterGetByG_F_PrevAndNext(session, journalArticle,
7305                                            groupId, folderId, orderByComparator, false);
7306    
7307                            return array;
7308                    }
7309                    catch (Exception e) {
7310                            throw processException(e);
7311                    }
7312                    finally {
7313                            closeSession(session);
7314                    }
7315            }
7316    
7317            protected JournalArticle filterGetByG_F_PrevAndNext(Session session,
7318                    JournalArticle journalArticle, long groupId, long folderId,
7319                    OrderByComparator orderByComparator, boolean previous) {
7320                    StringBundler query = null;
7321    
7322                    if (orderByComparator != null) {
7323                            query = new StringBundler(6 +
7324                                            (orderByComparator.getOrderByFields().length * 6));
7325                    }
7326                    else {
7327                            query = new StringBundler(3);
7328                    }
7329    
7330                    if (getDB().isSupportsInlineDistinct()) {
7331                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7332                    }
7333                    else {
7334                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7335                    }
7336    
7337                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
7338    
7339                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
7340    
7341                    if (!getDB().isSupportsInlineDistinct()) {
7342                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7343                    }
7344    
7345                    if (orderByComparator != null) {
7346                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7347    
7348                            if (orderByConditionFields.length > 0) {
7349                                    query.append(WHERE_AND);
7350                            }
7351    
7352                            for (int i = 0; i < orderByConditionFields.length; i++) {
7353                                    if (getDB().isSupportsInlineDistinct()) {
7354                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7355                                    }
7356                                    else {
7357                                            query.append(_ORDER_BY_ENTITY_TABLE);
7358                                    }
7359    
7360                                    query.append(orderByConditionFields[i]);
7361    
7362                                    if ((i + 1) < orderByConditionFields.length) {
7363                                            if (orderByComparator.isAscending() ^ previous) {
7364                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7365                                            }
7366                                            else {
7367                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7368                                            }
7369                                    }
7370                                    else {
7371                                            if (orderByComparator.isAscending() ^ previous) {
7372                                                    query.append(WHERE_GREATER_THAN);
7373                                            }
7374                                            else {
7375                                                    query.append(WHERE_LESSER_THAN);
7376                                            }
7377                                    }
7378                            }
7379    
7380                            query.append(ORDER_BY_CLAUSE);
7381    
7382                            String[] orderByFields = orderByComparator.getOrderByFields();
7383    
7384                            for (int i = 0; i < orderByFields.length; i++) {
7385                                    if (getDB().isSupportsInlineDistinct()) {
7386                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7387                                    }
7388                                    else {
7389                                            query.append(_ORDER_BY_ENTITY_TABLE);
7390                                    }
7391    
7392                                    query.append(orderByFields[i]);
7393    
7394                                    if ((i + 1) < orderByFields.length) {
7395                                            if (orderByComparator.isAscending() ^ previous) {
7396                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7397                                            }
7398                                            else {
7399                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7400                                            }
7401                                    }
7402                                    else {
7403                                            if (orderByComparator.isAscending() ^ previous) {
7404                                                    query.append(ORDER_BY_ASC);
7405                                            }
7406                                            else {
7407                                                    query.append(ORDER_BY_DESC);
7408                                            }
7409                                    }
7410                            }
7411                    }
7412                    else {
7413                            if (getDB().isSupportsInlineDistinct()) {
7414                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7415                            }
7416                            else {
7417                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7418                            }
7419                    }
7420    
7421                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7422                                    JournalArticle.class.getName(),
7423                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7424    
7425                    SQLQuery q = session.createSQLQuery(sql);
7426    
7427                    q.setFirstResult(0);
7428                    q.setMaxResults(2);
7429    
7430                    if (getDB().isSupportsInlineDistinct()) {
7431                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7432                    }
7433                    else {
7434                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7435                    }
7436    
7437                    QueryPos qPos = QueryPos.getInstance(q);
7438    
7439                    qPos.add(groupId);
7440    
7441                    qPos.add(folderId);
7442    
7443                    if (orderByComparator != null) {
7444                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7445    
7446                            for (Object value : values) {
7447                                    qPos.add(value);
7448                            }
7449                    }
7450    
7451                    List<JournalArticle> list = q.list();
7452    
7453                    if (list.size() == 2) {
7454                            return list.get(1);
7455                    }
7456                    else {
7457                            return null;
7458                    }
7459            }
7460    
7461            /**
7462             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
7463             *
7464             * @param groupId the group ID
7465             * @param folderIds the folder IDs
7466             * @return the matching journal articles that the user has permission to view
7467             * @throws SystemException if a system exception occurred
7468             */
7469            public List<JournalArticle> filterFindByG_F(long groupId, long[] folderIds)
7470                    throws SystemException {
7471                    return filterFindByG_F(groupId, folderIds, QueryUtil.ALL_POS,
7472                            QueryUtil.ALL_POS, null);
7473            }
7474    
7475            /**
7476             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
7477             *
7478             * <p>
7479             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7480             * </p>
7481             *
7482             * @param groupId the group ID
7483             * @param folderIds the folder IDs
7484             * @param start the lower bound of the range of journal articles
7485             * @param end the upper bound of the range of journal articles (not inclusive)
7486             * @return the range of matching journal articles that the user has permission to view
7487             * @throws SystemException if a system exception occurred
7488             */
7489            public List<JournalArticle> filterFindByG_F(long groupId, long[] folderIds,
7490                    int start, int end) throws SystemException {
7491                    return filterFindByG_F(groupId, folderIds, start, end, null);
7492            }
7493    
7494            /**
7495             * Returns an ordered range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
7496             *
7497             * <p>
7498             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7499             * </p>
7500             *
7501             * @param groupId the group ID
7502             * @param folderIds the folder IDs
7503             * @param start the lower bound of the range of journal articles
7504             * @param end the upper bound of the range of journal articles (not inclusive)
7505             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7506             * @return the ordered range of matching journal articles that the user has permission to view
7507             * @throws SystemException if a system exception occurred
7508             */
7509            public List<JournalArticle> filterFindByG_F(long groupId, long[] folderIds,
7510                    int start, int end, OrderByComparator orderByComparator)
7511                    throws SystemException {
7512                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7513                            return findByG_F(groupId, folderIds, start, end, orderByComparator);
7514                    }
7515    
7516                    StringBundler query = new StringBundler();
7517    
7518                    if (getDB().isSupportsInlineDistinct()) {
7519                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7520                    }
7521                    else {
7522                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7523                    }
7524    
7525                    boolean conjunctionable = false;
7526    
7527                    if (conjunctionable) {
7528                            query.append(WHERE_AND);
7529                    }
7530    
7531                    query.append(_FINDER_COLUMN_G_F_GROUPID_5);
7532    
7533                    conjunctionable = true;
7534    
7535                    if ((folderIds == null) || (folderIds.length > 0)) {
7536                            if (conjunctionable) {
7537                                    query.append(WHERE_AND);
7538                            }
7539    
7540                            query.append(StringPool.OPEN_PARENTHESIS);
7541    
7542                            for (int i = 0; i < folderIds.length; i++) {
7543                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
7544    
7545                                    if ((i + 1) < folderIds.length) {
7546                                            query.append(WHERE_OR);
7547                                    }
7548                            }
7549    
7550                            query.append(StringPool.CLOSE_PARENTHESIS);
7551    
7552                            conjunctionable = true;
7553                    }
7554    
7555                    if (!getDB().isSupportsInlineDistinct()) {
7556                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7557                    }
7558    
7559                    if (orderByComparator != null) {
7560                            if (getDB().isSupportsInlineDistinct()) {
7561                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7562                                            orderByComparator);
7563                            }
7564                            else {
7565                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7566                                            orderByComparator);
7567                            }
7568                    }
7569                    else {
7570                            if (getDB().isSupportsInlineDistinct()) {
7571                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7572                            }
7573                            else {
7574                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7575                            }
7576                    }
7577    
7578                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7579                                    JournalArticle.class.getName(),
7580                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7581    
7582                    Session session = null;
7583    
7584                    try {
7585                            session = openSession();
7586    
7587                            SQLQuery q = session.createSQLQuery(sql);
7588    
7589                            if (getDB().isSupportsInlineDistinct()) {
7590                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7591                            }
7592                            else {
7593                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7594                            }
7595    
7596                            QueryPos qPos = QueryPos.getInstance(q);
7597    
7598                            qPos.add(groupId);
7599    
7600                            if (folderIds != null) {
7601                                    qPos.add(folderIds);
7602                            }
7603    
7604                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
7605                                    end);
7606                    }
7607                    catch (Exception e) {
7608                            throw processException(e);
7609                    }
7610                    finally {
7611                            closeSession(session);
7612                    }
7613            }
7614    
7615            /**
7616             * Returns all the journal articles where groupId = &#63; and folderId = any &#63;.
7617             *
7618             * <p>
7619             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7620             * </p>
7621             *
7622             * @param groupId the group ID
7623             * @param folderIds the folder IDs
7624             * @return the matching journal articles
7625             * @throws SystemException if a system exception occurred
7626             */
7627            public List<JournalArticle> findByG_F(long groupId, long[] folderIds)
7628                    throws SystemException {
7629                    return findByG_F(groupId, folderIds, QueryUtil.ALL_POS,
7630                            QueryUtil.ALL_POS, null);
7631            }
7632    
7633            /**
7634             * Returns a range of all the journal articles where groupId = &#63; and folderId = any &#63;.
7635             *
7636             * <p>
7637             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7638             * </p>
7639             *
7640             * @param groupId the group ID
7641             * @param folderIds the folder IDs
7642             * @param start the lower bound of the range of journal articles
7643             * @param end the upper bound of the range of journal articles (not inclusive)
7644             * @return the range of matching journal articles
7645             * @throws SystemException if a system exception occurred
7646             */
7647            public List<JournalArticle> findByG_F(long groupId, long[] folderIds,
7648                    int start, int end) throws SystemException {
7649                    return findByG_F(groupId, folderIds, start, end, null);
7650            }
7651    
7652            /**
7653             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = any &#63;.
7654             *
7655             * <p>
7656             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7657             * </p>
7658             *
7659             * @param groupId the group ID
7660             * @param folderIds the folder IDs
7661             * @param start the lower bound of the range of journal articles
7662             * @param end the upper bound of the range of journal articles (not inclusive)
7663             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7664             * @return the ordered range of matching journal articles
7665             * @throws SystemException if a system exception occurred
7666             */
7667            public List<JournalArticle> findByG_F(long groupId, long[] folderIds,
7668                    int start, int end, OrderByComparator orderByComparator)
7669                    throws SystemException {
7670                    if ((folderIds != null) && (folderIds.length == 1)) {
7671                            return findByG_F(groupId, folderIds[0], start, end,
7672                                    orderByComparator);
7673                    }
7674    
7675                    boolean pagination = true;
7676                    Object[] finderArgs = null;
7677    
7678                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7679                                    (orderByComparator == null)) {
7680                            pagination = false;
7681                            finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
7682                    }
7683                    else {
7684                            finderArgs = new Object[] {
7685                                            groupId, StringUtil.merge(folderIds),
7686                                            
7687                                            start, end, orderByComparator
7688                                    };
7689                    }
7690    
7691                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
7692                                    finderArgs, this);
7693    
7694                    if ((list != null) && !list.isEmpty()) {
7695                            for (JournalArticle journalArticle : list) {
7696                                    if ((groupId != journalArticle.getGroupId()) ||
7697                                                    !ArrayUtil.contains(folderIds,
7698                                                            journalArticle.getFolderId())) {
7699                                            list = null;
7700    
7701                                            break;
7702                                    }
7703                            }
7704                    }
7705    
7706                    if (list == null) {
7707                            StringBundler query = new StringBundler();
7708    
7709                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7710    
7711                            boolean conjunctionable = false;
7712    
7713                            if (conjunctionable) {
7714                                    query.append(WHERE_AND);
7715                            }
7716    
7717                            query.append(_FINDER_COLUMN_G_F_GROUPID_5);
7718    
7719                            conjunctionable = true;
7720    
7721                            if ((folderIds == null) || (folderIds.length > 0)) {
7722                                    if (conjunctionable) {
7723                                            query.append(WHERE_AND);
7724                                    }
7725    
7726                                    query.append(StringPool.OPEN_PARENTHESIS);
7727    
7728                                    for (int i = 0; i < folderIds.length; i++) {
7729                                            query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
7730    
7731                                            if ((i + 1) < folderIds.length) {
7732                                                    query.append(WHERE_OR);
7733                                            }
7734                                    }
7735    
7736                                    query.append(StringPool.CLOSE_PARENTHESIS);
7737    
7738                                    conjunctionable = true;
7739                            }
7740    
7741                            if (orderByComparator != null) {
7742                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7743                                            orderByComparator);
7744                            }
7745                            else
7746                             if (pagination) {
7747                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7748                            }
7749    
7750                            String sql = query.toString();
7751    
7752                            Session session = null;
7753    
7754                            try {
7755                                    session = openSession();
7756    
7757                                    Query q = session.createQuery(sql);
7758    
7759                                    QueryPos qPos = QueryPos.getInstance(q);
7760    
7761                                    qPos.add(groupId);
7762    
7763                                    if (folderIds != null) {
7764                                            qPos.add(folderIds);
7765                                    }
7766    
7767                                    if (!pagination) {
7768                                            list = (List<JournalArticle>)QueryUtil.list(q,
7769                                                            getDialect(), start, end, false);
7770    
7771                                            Collections.sort(list);
7772    
7773                                            list = new UnmodifiableList<JournalArticle>(list);
7774                                    }
7775                                    else {
7776                                            list = (List<JournalArticle>)QueryUtil.list(q,
7777                                                            getDialect(), start, end);
7778                                    }
7779    
7780                                    cacheResult(list);
7781    
7782                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
7783                                            finderArgs, list);
7784                            }
7785                            catch (Exception e) {
7786                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
7787                                            finderArgs);
7788    
7789                                    throw processException(e);
7790                            }
7791                            finally {
7792                                    closeSession(session);
7793                            }
7794                    }
7795    
7796                    return list;
7797            }
7798    
7799            /**
7800             * Removes all the journal articles where groupId = &#63; and folderId = &#63; from the database.
7801             *
7802             * @param groupId the group ID
7803             * @param folderId the folder ID
7804             * @throws SystemException if a system exception occurred
7805             */
7806            public void removeByG_F(long groupId, long folderId)
7807                    throws SystemException {
7808                    for (JournalArticle journalArticle : findByG_F(groupId, folderId,
7809                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7810                            remove(journalArticle);
7811                    }
7812            }
7813    
7814            /**
7815             * Returns the number of journal articles where groupId = &#63; and folderId = &#63;.
7816             *
7817             * @param groupId the group ID
7818             * @param folderId the folder ID
7819             * @return the number of matching journal articles
7820             * @throws SystemException if a system exception occurred
7821             */
7822            public int countByG_F(long groupId, long folderId)
7823                    throws SystemException {
7824                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F;
7825    
7826                    Object[] finderArgs = new Object[] { groupId, folderId };
7827    
7828                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7829                                    this);
7830    
7831                    if (count == null) {
7832                            StringBundler query = new StringBundler(3);
7833    
7834                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
7835    
7836                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
7837    
7838                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
7839    
7840                            String sql = query.toString();
7841    
7842                            Session session = null;
7843    
7844                            try {
7845                                    session = openSession();
7846    
7847                                    Query q = session.createQuery(sql);
7848    
7849                                    QueryPos qPos = QueryPos.getInstance(q);
7850    
7851                                    qPos.add(groupId);
7852    
7853                                    qPos.add(folderId);
7854    
7855                                    count = (Long)q.uniqueResult();
7856    
7857                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
7858                            }
7859                            catch (Exception e) {
7860                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7861    
7862                                    throw processException(e);
7863                            }
7864                            finally {
7865                                    closeSession(session);
7866                            }
7867                    }
7868    
7869                    return count.intValue();
7870            }
7871    
7872            /**
7873             * Returns the number of journal articles where groupId = &#63; and folderId = any &#63;.
7874             *
7875             * @param groupId the group ID
7876             * @param folderIds the folder IDs
7877             * @return the number of matching journal articles
7878             * @throws SystemException if a system exception occurred
7879             */
7880            public int countByG_F(long groupId, long[] folderIds)
7881                    throws SystemException {
7882                    Object[] finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
7883    
7884                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
7885                                    finderArgs, this);
7886    
7887                    if (count == null) {
7888                            StringBundler query = new StringBundler();
7889    
7890                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
7891    
7892                            boolean conjunctionable = false;
7893    
7894                            if (conjunctionable) {
7895                                    query.append(WHERE_AND);
7896                            }
7897    
7898                            query.append(_FINDER_COLUMN_G_F_GROUPID_5);
7899    
7900                            conjunctionable = true;
7901    
7902                            if ((folderIds == null) || (folderIds.length > 0)) {
7903                                    if (conjunctionable) {
7904                                            query.append(WHERE_AND);
7905                                    }
7906    
7907                                    query.append(StringPool.OPEN_PARENTHESIS);
7908    
7909                                    for (int i = 0; i < folderIds.length; i++) {
7910                                            query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
7911    
7912                                            if ((i + 1) < folderIds.length) {
7913                                                    query.append(WHERE_OR);
7914                                            }
7915                                    }
7916    
7917                                    query.append(StringPool.CLOSE_PARENTHESIS);
7918    
7919                                    conjunctionable = true;
7920                            }
7921    
7922                            String sql = query.toString();
7923    
7924                            Session session = null;
7925    
7926                            try {
7927                                    session = openSession();
7928    
7929                                    Query q = session.createQuery(sql);
7930    
7931                                    QueryPos qPos = QueryPos.getInstance(q);
7932    
7933                                    qPos.add(groupId);
7934    
7935                                    if (folderIds != null) {
7936                                            qPos.add(folderIds);
7937                                    }
7938    
7939                                    count = (Long)q.uniqueResult();
7940    
7941                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
7942                                            finderArgs, count);
7943                            }
7944                            catch (Exception e) {
7945                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
7946                                            finderArgs);
7947    
7948                                    throw processException(e);
7949                            }
7950                            finally {
7951                                    closeSession(session);
7952                            }
7953                    }
7954    
7955                    return count.intValue();
7956            }
7957    
7958            /**
7959             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
7960             *
7961             * @param groupId the group ID
7962             * @param folderId the folder ID
7963             * @return the number of matching journal articles that the user has permission to view
7964             * @throws SystemException if a system exception occurred
7965             */
7966            public int filterCountByG_F(long groupId, long folderId)
7967                    throws SystemException {
7968                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7969                            return countByG_F(groupId, folderId);
7970                    }
7971    
7972                    StringBundler query = new StringBundler(3);
7973    
7974                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
7975    
7976                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
7977    
7978                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
7979    
7980                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7981                                    JournalArticle.class.getName(),
7982                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7983    
7984                    Session session = null;
7985    
7986                    try {
7987                            session = openSession();
7988    
7989                            SQLQuery q = session.createSQLQuery(sql);
7990    
7991                            q.addScalar(COUNT_COLUMN_NAME,
7992                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
7993    
7994                            QueryPos qPos = QueryPos.getInstance(q);
7995    
7996                            qPos.add(groupId);
7997    
7998                            qPos.add(folderId);
7999    
8000                            Long count = (Long)q.uniqueResult();
8001    
8002                            return count.intValue();
8003                    }
8004                    catch (Exception e) {
8005                            throw processException(e);
8006                    }
8007                    finally {
8008                            closeSession(session);
8009                    }
8010            }
8011    
8012            /**
8013             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
8014             *
8015             * @param groupId the group ID
8016             * @param folderIds the folder IDs
8017             * @return the number of matching journal articles that the user has permission to view
8018             * @throws SystemException if a system exception occurred
8019             */
8020            public int filterCountByG_F(long groupId, long[] folderIds)
8021                    throws SystemException {
8022                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8023                            return countByG_F(groupId, folderIds);
8024                    }
8025    
8026                    StringBundler query = new StringBundler();
8027    
8028                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
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                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8061                                    JournalArticle.class.getName(),
8062                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8063    
8064                    Session session = null;
8065    
8066                    try {
8067                            session = openSession();
8068    
8069                            SQLQuery q = session.createSQLQuery(sql);
8070    
8071                            q.addScalar(COUNT_COLUMN_NAME,
8072                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
8073    
8074                            QueryPos qPos = QueryPos.getInstance(q);
8075    
8076                            qPos.add(groupId);
8077    
8078                            if (folderIds != null) {
8079                                    qPos.add(folderIds);
8080                            }
8081    
8082                            Long count = (Long)q.uniqueResult();
8083    
8084                            return count.intValue();
8085                    }
8086                    catch (Exception e) {
8087                            throw processException(e);
8088                    }
8089                    finally {
8090                            closeSession(session);
8091                    }
8092            }
8093    
8094            private static final String _FINDER_COLUMN_G_F_GROUPID_2 = "journalArticle.groupId = ? AND ";
8095            private static final String _FINDER_COLUMN_G_F_GROUPID_5 = "(" +
8096                    _removeConjunction(_FINDER_COLUMN_G_F_GROUPID_2) + ")";
8097            private static final String _FINDER_COLUMN_G_F_FOLDERID_2 = "journalArticle.folderId = ?";
8098            private static final String _FINDER_COLUMN_G_F_FOLDERID_5 = "(" +
8099                    _removeConjunction(_FINDER_COLUMN_G_F_FOLDERID_2) + ")";
8100            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
8101                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
8102                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
8103                            "findByG_A",
8104                            new String[] {
8105                                    Long.class.getName(), String.class.getName(),
8106                                    
8107                            Integer.class.getName(), Integer.class.getName(),
8108                                    OrderByComparator.class.getName()
8109                            });
8110            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
8111                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
8112                            JournalArticleImpl.class,
8113                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A",
8114                            new String[] { Long.class.getName(), String.class.getName() },
8115                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
8116                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
8117                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
8118            public static final FinderPath FINDER_PATH_COUNT_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
8119                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
8120                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A",
8121                            new String[] { Long.class.getName(), String.class.getName() });
8122    
8123            /**
8124             * Returns all the journal articles where groupId = &#63; and articleId = &#63;.
8125             *
8126             * @param groupId the group ID
8127             * @param articleId the article ID
8128             * @return the matching journal articles
8129             * @throws SystemException if a system exception occurred
8130             */
8131            public List<JournalArticle> findByG_A(long groupId, String articleId)
8132                    throws SystemException {
8133                    return findByG_A(groupId, articleId, QueryUtil.ALL_POS,
8134                            QueryUtil.ALL_POS, null);
8135            }
8136    
8137            /**
8138             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63;.
8139             *
8140             * <p>
8141             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8142             * </p>
8143             *
8144             * @param groupId the group ID
8145             * @param articleId the article ID
8146             * @param start the lower bound of the range of journal articles
8147             * @param end the upper bound of the range of journal articles (not inclusive)
8148             * @return the range of matching journal articles
8149             * @throws SystemException if a system exception occurred
8150             */
8151            public List<JournalArticle> findByG_A(long groupId, String articleId,
8152                    int start, int end) throws SystemException {
8153                    return findByG_A(groupId, articleId, start, end, null);
8154            }
8155    
8156            /**
8157             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63;.
8158             *
8159             * <p>
8160             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8161             * </p>
8162             *
8163             * @param groupId the group ID
8164             * @param articleId the article ID
8165             * @param start the lower bound of the range of journal articles
8166             * @param end the upper bound of the range of journal articles (not inclusive)
8167             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8168             * @return the ordered range of matching journal articles
8169             * @throws SystemException if a system exception occurred
8170             */
8171            public List<JournalArticle> findByG_A(long groupId, String articleId,
8172                    int start, int end, OrderByComparator orderByComparator)
8173                    throws SystemException {
8174                    boolean pagination = true;
8175                    FinderPath finderPath = null;
8176                    Object[] finderArgs = null;
8177    
8178                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8179                                    (orderByComparator == null)) {
8180                            pagination = false;
8181                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A;
8182                            finderArgs = new Object[] { groupId, articleId };
8183                    }
8184                    else {
8185                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A;
8186                            finderArgs = new Object[] {
8187                                            groupId, articleId,
8188                                            
8189                                            start, end, orderByComparator
8190                                    };
8191                    }
8192    
8193                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
8194                                    finderArgs, this);
8195    
8196                    if ((list != null) && !list.isEmpty()) {
8197                            for (JournalArticle journalArticle : list) {
8198                                    if ((groupId != journalArticle.getGroupId()) ||
8199                                                    !Validator.equals(articleId,
8200                                                            journalArticle.getArticleId())) {
8201                                            list = null;
8202    
8203                                            break;
8204                                    }
8205                            }
8206                    }
8207    
8208                    if (list == null) {
8209                            StringBundler query = null;
8210    
8211                            if (orderByComparator != null) {
8212                                    query = new StringBundler(4 +
8213                                                    (orderByComparator.getOrderByFields().length * 3));
8214                            }
8215                            else {
8216                                    query = new StringBundler(4);
8217                            }
8218    
8219                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8220    
8221                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
8222    
8223                            if (articleId == null) {
8224                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
8225                            }
8226                            else {
8227                                    if (articleId.equals(StringPool.BLANK)) {
8228                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
8229                                    }
8230                                    else {
8231                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
8232                                    }
8233                            }
8234    
8235                            if (orderByComparator != null) {
8236                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8237                                            orderByComparator);
8238                            }
8239                            else
8240                             if (pagination) {
8241                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8242                            }
8243    
8244                            String sql = query.toString();
8245    
8246                            Session session = null;
8247    
8248                            try {
8249                                    session = openSession();
8250    
8251                                    Query q = session.createQuery(sql);
8252    
8253                                    QueryPos qPos = QueryPos.getInstance(q);
8254    
8255                                    qPos.add(groupId);
8256    
8257                                    if (articleId != null) {
8258                                            qPos.add(articleId);
8259                                    }
8260    
8261                                    if (!pagination) {
8262                                            list = (List<JournalArticle>)QueryUtil.list(q,
8263                                                            getDialect(), start, end, false);
8264    
8265                                            Collections.sort(list);
8266    
8267                                            list = new UnmodifiableList<JournalArticle>(list);
8268                                    }
8269                                    else {
8270                                            list = (List<JournalArticle>)QueryUtil.list(q,
8271                                                            getDialect(), start, end);
8272                                    }
8273    
8274                                    cacheResult(list);
8275    
8276                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
8277                            }
8278                            catch (Exception e) {
8279                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8280    
8281                                    throw processException(e);
8282                            }
8283                            finally {
8284                                    closeSession(session);
8285                            }
8286                    }
8287    
8288                    return list;
8289            }
8290    
8291            /**
8292             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63;.
8293             *
8294             * @param groupId the group ID
8295             * @param articleId the article ID
8296             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8297             * @return the first matching journal article
8298             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
8299             * @throws SystemException if a system exception occurred
8300             */
8301            public JournalArticle findByG_A_First(long groupId, String articleId,
8302                    OrderByComparator orderByComparator)
8303                    throws NoSuchArticleException, SystemException {
8304                    JournalArticle journalArticle = fetchByG_A_First(groupId, articleId,
8305                                    orderByComparator);
8306    
8307                    if (journalArticle != null) {
8308                            return journalArticle;
8309                    }
8310    
8311                    StringBundler msg = new StringBundler(6);
8312    
8313                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8314    
8315                    msg.append("groupId=");
8316                    msg.append(groupId);
8317    
8318                    msg.append(", articleId=");
8319                    msg.append(articleId);
8320    
8321                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8322    
8323                    throw new NoSuchArticleException(msg.toString());
8324            }
8325    
8326            /**
8327             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63;.
8328             *
8329             * @param groupId the group ID
8330             * @param articleId the article ID
8331             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8332             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
8333             * @throws SystemException if a system exception occurred
8334             */
8335            public JournalArticle fetchByG_A_First(long groupId, String articleId,
8336                    OrderByComparator orderByComparator) throws SystemException {
8337                    List<JournalArticle> list = findByG_A(groupId, articleId, 0, 1,
8338                                    orderByComparator);
8339    
8340                    if (!list.isEmpty()) {
8341                            return list.get(0);
8342                    }
8343    
8344                    return null;
8345            }
8346    
8347            /**
8348             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63;.
8349             *
8350             * @param groupId the group ID
8351             * @param articleId the article ID
8352             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8353             * @return the last matching journal article
8354             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
8355             * @throws SystemException if a system exception occurred
8356             */
8357            public JournalArticle findByG_A_Last(long groupId, String articleId,
8358                    OrderByComparator orderByComparator)
8359                    throws NoSuchArticleException, SystemException {
8360                    JournalArticle journalArticle = fetchByG_A_Last(groupId, articleId,
8361                                    orderByComparator);
8362    
8363                    if (journalArticle != null) {
8364                            return journalArticle;
8365                    }
8366    
8367                    StringBundler msg = new StringBundler(6);
8368    
8369                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8370    
8371                    msg.append("groupId=");
8372                    msg.append(groupId);
8373    
8374                    msg.append(", articleId=");
8375                    msg.append(articleId);
8376    
8377                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8378    
8379                    throw new NoSuchArticleException(msg.toString());
8380            }
8381    
8382            /**
8383             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63;.
8384             *
8385             * @param groupId the group ID
8386             * @param articleId the article ID
8387             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8388             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
8389             * @throws SystemException if a system exception occurred
8390             */
8391            public JournalArticle fetchByG_A_Last(long groupId, String articleId,
8392                    OrderByComparator orderByComparator) throws SystemException {
8393                    int count = countByG_A(groupId, articleId);
8394    
8395                    List<JournalArticle> list = findByG_A(groupId, articleId, count - 1,
8396                                    count, orderByComparator);
8397    
8398                    if (!list.isEmpty()) {
8399                            return list.get(0);
8400                    }
8401    
8402                    return null;
8403            }
8404    
8405            /**
8406             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63;.
8407             *
8408             * @param id the primary key of the current journal article
8409             * @param groupId the group ID
8410             * @param articleId the article ID
8411             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8412             * @return the previous, current, and next journal article
8413             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
8414             * @throws SystemException if a system exception occurred
8415             */
8416            public JournalArticle[] findByG_A_PrevAndNext(long id, long groupId,
8417                    String articleId, OrderByComparator orderByComparator)
8418                    throws NoSuchArticleException, SystemException {
8419                    JournalArticle journalArticle = findByPrimaryKey(id);
8420    
8421                    Session session = null;
8422    
8423                    try {
8424                            session = openSession();
8425    
8426                            JournalArticle[] array = new JournalArticleImpl[3];
8427    
8428                            array[0] = getByG_A_PrevAndNext(session, journalArticle, groupId,
8429                                            articleId, orderByComparator, true);
8430    
8431                            array[1] = journalArticle;
8432    
8433                            array[2] = getByG_A_PrevAndNext(session, journalArticle, groupId,
8434                                            articleId, orderByComparator, false);
8435    
8436                            return array;
8437                    }
8438                    catch (Exception e) {
8439                            throw processException(e);
8440                    }
8441                    finally {
8442                            closeSession(session);
8443                    }
8444            }
8445    
8446            protected JournalArticle getByG_A_PrevAndNext(Session session,
8447                    JournalArticle journalArticle, long groupId, String articleId,
8448                    OrderByComparator orderByComparator, boolean previous) {
8449                    StringBundler query = null;
8450    
8451                    if (orderByComparator != null) {
8452                            query = new StringBundler(6 +
8453                                            (orderByComparator.getOrderByFields().length * 6));
8454                    }
8455                    else {
8456                            query = new StringBundler(3);
8457                    }
8458    
8459                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8460    
8461                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
8462    
8463                    if (articleId == null) {
8464                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
8465                    }
8466                    else {
8467                            if (articleId.equals(StringPool.BLANK)) {
8468                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
8469                            }
8470                            else {
8471                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
8472                            }
8473                    }
8474    
8475                    if (orderByComparator != null) {
8476                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8477    
8478                            if (orderByConditionFields.length > 0) {
8479                                    query.append(WHERE_AND);
8480                            }
8481    
8482                            for (int i = 0; i < orderByConditionFields.length; i++) {
8483                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8484                                    query.append(orderByConditionFields[i]);
8485    
8486                                    if ((i + 1) < orderByConditionFields.length) {
8487                                            if (orderByComparator.isAscending() ^ previous) {
8488                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8489                                            }
8490                                            else {
8491                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8492                                            }
8493                                    }
8494                                    else {
8495                                            if (orderByComparator.isAscending() ^ previous) {
8496                                                    query.append(WHERE_GREATER_THAN);
8497                                            }
8498                                            else {
8499                                                    query.append(WHERE_LESSER_THAN);
8500                                            }
8501                                    }
8502                            }
8503    
8504                            query.append(ORDER_BY_CLAUSE);
8505    
8506                            String[] orderByFields = orderByComparator.getOrderByFields();
8507    
8508                            for (int i = 0; i < orderByFields.length; i++) {
8509                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8510                                    query.append(orderByFields[i]);
8511    
8512                                    if ((i + 1) < orderByFields.length) {
8513                                            if (orderByComparator.isAscending() ^ previous) {
8514                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8515                                            }
8516                                            else {
8517                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8518                                            }
8519                                    }
8520                                    else {
8521                                            if (orderByComparator.isAscending() ^ previous) {
8522                                                    query.append(ORDER_BY_ASC);
8523                                            }
8524                                            else {
8525                                                    query.append(ORDER_BY_DESC);
8526                                            }
8527                                    }
8528                            }
8529                    }
8530                    else {
8531                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8532                    }
8533    
8534                    String sql = query.toString();
8535    
8536                    Query q = session.createQuery(sql);
8537    
8538                    q.setFirstResult(0);
8539                    q.setMaxResults(2);
8540    
8541                    QueryPos qPos = QueryPos.getInstance(q);
8542    
8543                    qPos.add(groupId);
8544    
8545                    if (articleId != null) {
8546                            qPos.add(articleId);
8547                    }
8548    
8549                    if (orderByComparator != null) {
8550                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
8551    
8552                            for (Object value : values) {
8553                                    qPos.add(value);
8554                            }
8555                    }
8556    
8557                    List<JournalArticle> list = q.list();
8558    
8559                    if (list.size() == 2) {
8560                            return list.get(1);
8561                    }
8562                    else {
8563                            return null;
8564                    }
8565            }
8566    
8567            /**
8568             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
8569             *
8570             * @param groupId the group ID
8571             * @param articleId the article ID
8572             * @return the matching journal articles that the user has permission to view
8573             * @throws SystemException if a system exception occurred
8574             */
8575            public List<JournalArticle> filterFindByG_A(long groupId, String articleId)
8576                    throws SystemException {
8577                    return filterFindByG_A(groupId, articleId, QueryUtil.ALL_POS,
8578                            QueryUtil.ALL_POS, null);
8579            }
8580    
8581            /**
8582             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
8583             *
8584             * <p>
8585             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8586             * </p>
8587             *
8588             * @param groupId the group ID
8589             * @param articleId the article ID
8590             * @param start the lower bound of the range of journal articles
8591             * @param end the upper bound of the range of journal articles (not inclusive)
8592             * @return the range of matching journal articles that the user has permission to view
8593             * @throws SystemException if a system exception occurred
8594             */
8595            public List<JournalArticle> filterFindByG_A(long groupId, String articleId,
8596                    int start, int end) throws SystemException {
8597                    return filterFindByG_A(groupId, articleId, start, end, null);
8598            }
8599    
8600            /**
8601             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and articleId = &#63;.
8602             *
8603             * <p>
8604             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8605             * </p>
8606             *
8607             * @param groupId the group ID
8608             * @param articleId the article ID
8609             * @param start the lower bound of the range of journal articles
8610             * @param end the upper bound of the range of journal articles (not inclusive)
8611             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8612             * @return the ordered range of matching journal articles that the user has permission to view
8613             * @throws SystemException if a system exception occurred
8614             */
8615            public List<JournalArticle> filterFindByG_A(long groupId, String articleId,
8616                    int start, int end, OrderByComparator orderByComparator)
8617                    throws SystemException {
8618                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8619                            return findByG_A(groupId, articleId, start, end, orderByComparator);
8620                    }
8621    
8622                    StringBundler query = null;
8623    
8624                    if (orderByComparator != null) {
8625                            query = new StringBundler(4 +
8626                                            (orderByComparator.getOrderByFields().length * 3));
8627                    }
8628                    else {
8629                            query = new StringBundler(4);
8630                    }
8631    
8632                    if (getDB().isSupportsInlineDistinct()) {
8633                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8634                    }
8635                    else {
8636                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8637                    }
8638    
8639                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
8640    
8641                    if (articleId == null) {
8642                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
8643                    }
8644                    else {
8645                            if (articleId.equals(StringPool.BLANK)) {
8646                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
8647                            }
8648                            else {
8649                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
8650                            }
8651                    }
8652    
8653                    if (!getDB().isSupportsInlineDistinct()) {
8654                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8655                    }
8656    
8657                    if (orderByComparator != null) {
8658                            if (getDB().isSupportsInlineDistinct()) {
8659                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8660                                            orderByComparator);
8661                            }
8662                            else {
8663                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8664                                            orderByComparator);
8665                            }
8666                    }
8667                    else {
8668                            if (getDB().isSupportsInlineDistinct()) {
8669                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8670                            }
8671                            else {
8672                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8673                            }
8674                    }
8675    
8676                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8677                                    JournalArticle.class.getName(),
8678                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8679    
8680                    Session session = null;
8681    
8682                    try {
8683                            session = openSession();
8684    
8685                            SQLQuery q = session.createSQLQuery(sql);
8686    
8687                            if (getDB().isSupportsInlineDistinct()) {
8688                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8689                            }
8690                            else {
8691                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8692                            }
8693    
8694                            QueryPos qPos = QueryPos.getInstance(q);
8695    
8696                            qPos.add(groupId);
8697    
8698                            if (articleId != null) {
8699                                    qPos.add(articleId);
8700                            }
8701    
8702                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
8703                                    end);
8704                    }
8705                    catch (Exception e) {
8706                            throw processException(e);
8707                    }
8708                    finally {
8709                            closeSession(session);
8710                    }
8711            }
8712    
8713            /**
8714             * 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;.
8715             *
8716             * @param id the primary key of the current journal article
8717             * @param groupId the group ID
8718             * @param articleId the article ID
8719             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8720             * @return the previous, current, and next journal article
8721             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
8722             * @throws SystemException if a system exception occurred
8723             */
8724            public JournalArticle[] filterFindByG_A_PrevAndNext(long id, long groupId,
8725                    String articleId, OrderByComparator orderByComparator)
8726                    throws NoSuchArticleException, SystemException {
8727                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8728                            return findByG_A_PrevAndNext(id, groupId, articleId,
8729                                    orderByComparator);
8730                    }
8731    
8732                    JournalArticle journalArticle = findByPrimaryKey(id);
8733    
8734                    Session session = null;
8735    
8736                    try {
8737                            session = openSession();
8738    
8739                            JournalArticle[] array = new JournalArticleImpl[3];
8740    
8741                            array[0] = filterGetByG_A_PrevAndNext(session, journalArticle,
8742                                            groupId, articleId, orderByComparator, true);
8743    
8744                            array[1] = journalArticle;
8745    
8746                            array[2] = filterGetByG_A_PrevAndNext(session, journalArticle,
8747                                            groupId, articleId, orderByComparator, false);
8748    
8749                            return array;
8750                    }
8751                    catch (Exception e) {
8752                            throw processException(e);
8753                    }
8754                    finally {
8755                            closeSession(session);
8756                    }
8757            }
8758    
8759            protected JournalArticle filterGetByG_A_PrevAndNext(Session session,
8760                    JournalArticle journalArticle, long groupId, String articleId,
8761                    OrderByComparator orderByComparator, boolean previous) {
8762                    StringBundler query = null;
8763    
8764                    if (orderByComparator != null) {
8765                            query = new StringBundler(6 +
8766                                            (orderByComparator.getOrderByFields().length * 6));
8767                    }
8768                    else {
8769                            query = new StringBundler(3);
8770                    }
8771    
8772                    if (getDB().isSupportsInlineDistinct()) {
8773                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8774                    }
8775                    else {
8776                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8777                    }
8778    
8779                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
8780    
8781                    if (articleId == null) {
8782                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
8783                    }
8784                    else {
8785                            if (articleId.equals(StringPool.BLANK)) {
8786                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
8787                            }
8788                            else {
8789                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
8790                            }
8791                    }
8792    
8793                    if (!getDB().isSupportsInlineDistinct()) {
8794                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8795                    }
8796    
8797                    if (orderByComparator != null) {
8798                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8799    
8800                            if (orderByConditionFields.length > 0) {
8801                                    query.append(WHERE_AND);
8802                            }
8803    
8804                            for (int i = 0; i < orderByConditionFields.length; i++) {
8805                                    if (getDB().isSupportsInlineDistinct()) {
8806                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8807                                    }
8808                                    else {
8809                                            query.append(_ORDER_BY_ENTITY_TABLE);
8810                                    }
8811    
8812                                    query.append(orderByConditionFields[i]);
8813    
8814                                    if ((i + 1) < orderByConditionFields.length) {
8815                                            if (orderByComparator.isAscending() ^ previous) {
8816                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8817                                            }
8818                                            else {
8819                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8820                                            }
8821                                    }
8822                                    else {
8823                                            if (orderByComparator.isAscending() ^ previous) {
8824                                                    query.append(WHERE_GREATER_THAN);
8825                                            }
8826                                            else {
8827                                                    query.append(WHERE_LESSER_THAN);
8828                                            }
8829                                    }
8830                            }
8831    
8832                            query.append(ORDER_BY_CLAUSE);
8833    
8834                            String[] orderByFields = orderByComparator.getOrderByFields();
8835    
8836                            for (int i = 0; i < orderByFields.length; i++) {
8837                                    if (getDB().isSupportsInlineDistinct()) {
8838                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8839                                    }
8840                                    else {
8841                                            query.append(_ORDER_BY_ENTITY_TABLE);
8842                                    }
8843    
8844                                    query.append(orderByFields[i]);
8845    
8846                                    if ((i + 1) < orderByFields.length) {
8847                                            if (orderByComparator.isAscending() ^ previous) {
8848                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8849                                            }
8850                                            else {
8851                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8852                                            }
8853                                    }
8854                                    else {
8855                                            if (orderByComparator.isAscending() ^ previous) {
8856                                                    query.append(ORDER_BY_ASC);
8857                                            }
8858                                            else {
8859                                                    query.append(ORDER_BY_DESC);
8860                                            }
8861                                    }
8862                            }
8863                    }
8864                    else {
8865                            if (getDB().isSupportsInlineDistinct()) {
8866                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8867                            }
8868                            else {
8869                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8870                            }
8871                    }
8872    
8873                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8874                                    JournalArticle.class.getName(),
8875                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8876    
8877                    SQLQuery q = session.createSQLQuery(sql);
8878    
8879                    q.setFirstResult(0);
8880                    q.setMaxResults(2);
8881    
8882                    if (getDB().isSupportsInlineDistinct()) {
8883                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8884                    }
8885                    else {
8886                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8887                    }
8888    
8889                    QueryPos qPos = QueryPos.getInstance(q);
8890    
8891                    qPos.add(groupId);
8892    
8893                    if (articleId != null) {
8894                            qPos.add(articleId);
8895                    }
8896    
8897                    if (orderByComparator != null) {
8898                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
8899    
8900                            for (Object value : values) {
8901                                    qPos.add(value);
8902                            }
8903                    }
8904    
8905                    List<JournalArticle> list = q.list();
8906    
8907                    if (list.size() == 2) {
8908                            return list.get(1);
8909                    }
8910                    else {
8911                            return null;
8912                    }
8913            }
8914    
8915            /**
8916             * Removes all the journal articles where groupId = &#63; and articleId = &#63; from the database.
8917             *
8918             * @param groupId the group ID
8919             * @param articleId the article ID
8920             * @throws SystemException if a system exception occurred
8921             */
8922            public void removeByG_A(long groupId, String articleId)
8923                    throws SystemException {
8924                    for (JournalArticle journalArticle : findByG_A(groupId, articleId,
8925                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8926                            remove(journalArticle);
8927                    }
8928            }
8929    
8930            /**
8931             * Returns the number of journal articles where groupId = &#63; and articleId = &#63;.
8932             *
8933             * @param groupId the group ID
8934             * @param articleId the article ID
8935             * @return the number of matching journal articles
8936             * @throws SystemException if a system exception occurred
8937             */
8938            public int countByG_A(long groupId, String articleId)
8939                    throws SystemException {
8940                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A;
8941    
8942                    Object[] finderArgs = new Object[] { groupId, articleId };
8943    
8944                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
8945                                    this);
8946    
8947                    if (count == null) {
8948                            StringBundler query = new StringBundler(3);
8949    
8950                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
8951    
8952                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
8953    
8954                            if (articleId == null) {
8955                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
8956                            }
8957                            else {
8958                                    if (articleId.equals(StringPool.BLANK)) {
8959                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
8960                                    }
8961                                    else {
8962                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
8963                                    }
8964                            }
8965    
8966                            String sql = query.toString();
8967    
8968                            Session session = null;
8969    
8970                            try {
8971                                    session = openSession();
8972    
8973                                    Query q = session.createQuery(sql);
8974    
8975                                    QueryPos qPos = QueryPos.getInstance(q);
8976    
8977                                    qPos.add(groupId);
8978    
8979                                    if (articleId != null) {
8980                                            qPos.add(articleId);
8981                                    }
8982    
8983                                    count = (Long)q.uniqueResult();
8984    
8985                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
8986                            }
8987                            catch (Exception e) {
8988                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8989    
8990                                    throw processException(e);
8991                            }
8992                            finally {
8993                                    closeSession(session);
8994                            }
8995                    }
8996    
8997                    return count.intValue();
8998            }
8999    
9000            /**
9001             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
9002             *
9003             * @param groupId the group ID
9004             * @param articleId the article ID
9005             * @return the number of matching journal articles that the user has permission to view
9006             * @throws SystemException if a system exception occurred
9007             */
9008            public int filterCountByG_A(long groupId, String articleId)
9009                    throws SystemException {
9010                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9011                            return countByG_A(groupId, articleId);
9012                    }
9013    
9014                    StringBundler query = new StringBundler(3);
9015    
9016                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
9017    
9018                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
9019    
9020                    if (articleId == null) {
9021                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
9022                    }
9023                    else {
9024                            if (articleId.equals(StringPool.BLANK)) {
9025                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
9026                            }
9027                            else {
9028                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
9029                            }
9030                    }
9031    
9032                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9033                                    JournalArticle.class.getName(),
9034                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9035    
9036                    Session session = null;
9037    
9038                    try {
9039                            session = openSession();
9040    
9041                            SQLQuery q = session.createSQLQuery(sql);
9042    
9043                            q.addScalar(COUNT_COLUMN_NAME,
9044                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9045    
9046                            QueryPos qPos = QueryPos.getInstance(q);
9047    
9048                            qPos.add(groupId);
9049    
9050                            if (articleId != null) {
9051                                    qPos.add(articleId);
9052                            }
9053    
9054                            Long count = (Long)q.uniqueResult();
9055    
9056                            return count.intValue();
9057                    }
9058                    catch (Exception e) {
9059                            throw processException(e);
9060                    }
9061                    finally {
9062                            closeSession(session);
9063                    }
9064            }
9065    
9066            private static final String _FINDER_COLUMN_G_A_GROUPID_2 = "journalArticle.groupId = ? AND ";
9067            private static final String _FINDER_COLUMN_G_A_ARTICLEID_1 = "journalArticle.articleId IS NULL";
9068            private static final String _FINDER_COLUMN_G_A_ARTICLEID_2 = "journalArticle.articleId = ?";
9069            private static final String _FINDER_COLUMN_G_A_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = ?)";
9070            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
9071                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
9072                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
9073                            "findByG_UT",
9074                            new String[] {
9075                                    Long.class.getName(), String.class.getName(),
9076                                    
9077                            Integer.class.getName(), Integer.class.getName(),
9078                                    OrderByComparator.class.getName()
9079                            });
9080            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
9081                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
9082                            JournalArticleImpl.class,
9083                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_UT",
9084                            new String[] { Long.class.getName(), String.class.getName() },
9085                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
9086                            JournalArticleModelImpl.URLTITLE_COLUMN_BITMASK |
9087                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
9088                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
9089            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
9090                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
9091                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT",
9092                            new String[] { Long.class.getName(), String.class.getName() });
9093    
9094            /**
9095             * Returns all the journal articles where groupId = &#63; and urlTitle = &#63;.
9096             *
9097             * @param groupId the group ID
9098             * @param urlTitle the url title
9099             * @return the matching journal articles
9100             * @throws SystemException if a system exception occurred
9101             */
9102            public List<JournalArticle> findByG_UT(long groupId, String urlTitle)
9103                    throws SystemException {
9104                    return findByG_UT(groupId, urlTitle, QueryUtil.ALL_POS,
9105                            QueryUtil.ALL_POS, null);
9106            }
9107    
9108            /**
9109             * Returns a range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
9110             *
9111             * <p>
9112             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9113             * </p>
9114             *
9115             * @param groupId the group ID
9116             * @param urlTitle the url title
9117             * @param start the lower bound of the range of journal articles
9118             * @param end the upper bound of the range of journal articles (not inclusive)
9119             * @return the range of matching journal articles
9120             * @throws SystemException if a system exception occurred
9121             */
9122            public List<JournalArticle> findByG_UT(long groupId, String urlTitle,
9123                    int start, int end) throws SystemException {
9124                    return findByG_UT(groupId, urlTitle, start, end, null);
9125            }
9126    
9127            /**
9128             * Returns an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
9129             *
9130             * <p>
9131             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9132             * </p>
9133             *
9134             * @param groupId the group ID
9135             * @param urlTitle the url title
9136             * @param start the lower bound of the range of journal articles
9137             * @param end the upper bound of the range of journal articles (not inclusive)
9138             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9139             * @return the ordered range of matching journal articles
9140             * @throws SystemException if a system exception occurred
9141             */
9142            public List<JournalArticle> findByG_UT(long groupId, String urlTitle,
9143                    int start, int end, OrderByComparator orderByComparator)
9144                    throws SystemException {
9145                    boolean pagination = true;
9146                    FinderPath finderPath = null;
9147                    Object[] finderArgs = null;
9148    
9149                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9150                                    (orderByComparator == null)) {
9151                            pagination = false;
9152                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT;
9153                            finderArgs = new Object[] { groupId, urlTitle };
9154                    }
9155                    else {
9156                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT;
9157                            finderArgs = new Object[] {
9158                                            groupId, urlTitle,
9159                                            
9160                                            start, end, orderByComparator
9161                                    };
9162                    }
9163    
9164                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
9165                                    finderArgs, this);
9166    
9167                    if ((list != null) && !list.isEmpty()) {
9168                            for (JournalArticle journalArticle : list) {
9169                                    if ((groupId != journalArticle.getGroupId()) ||
9170                                                    !Validator.equals(urlTitle, journalArticle.getUrlTitle())) {
9171                                            list = null;
9172    
9173                                            break;
9174                                    }
9175                            }
9176                    }
9177    
9178                    if (list == null) {
9179                            StringBundler query = null;
9180    
9181                            if (orderByComparator != null) {
9182                                    query = new StringBundler(4 +
9183                                                    (orderByComparator.getOrderByFields().length * 3));
9184                            }
9185                            else {
9186                                    query = new StringBundler(4);
9187                            }
9188    
9189                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9190    
9191                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
9192    
9193                            if (urlTitle == null) {
9194                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
9195                            }
9196                            else {
9197                                    if (urlTitle.equals(StringPool.BLANK)) {
9198                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
9199                                    }
9200                                    else {
9201                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
9202                                    }
9203                            }
9204    
9205                            if (orderByComparator != null) {
9206                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9207                                            orderByComparator);
9208                            }
9209                            else
9210                             if (pagination) {
9211                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9212                            }
9213    
9214                            String sql = query.toString();
9215    
9216                            Session session = null;
9217    
9218                            try {
9219                                    session = openSession();
9220    
9221                                    Query q = session.createQuery(sql);
9222    
9223                                    QueryPos qPos = QueryPos.getInstance(q);
9224    
9225                                    qPos.add(groupId);
9226    
9227                                    if (urlTitle != null) {
9228                                            qPos.add(urlTitle);
9229                                    }
9230    
9231                                    if (!pagination) {
9232                                            list = (List<JournalArticle>)QueryUtil.list(q,
9233                                                            getDialect(), start, end, false);
9234    
9235                                            Collections.sort(list);
9236    
9237                                            list = new UnmodifiableList<JournalArticle>(list);
9238                                    }
9239                                    else {
9240                                            list = (List<JournalArticle>)QueryUtil.list(q,
9241                                                            getDialect(), start, end);
9242                                    }
9243    
9244                                    cacheResult(list);
9245    
9246                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
9247                            }
9248                            catch (Exception e) {
9249                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9250    
9251                                    throw processException(e);
9252                            }
9253                            finally {
9254                                    closeSession(session);
9255                            }
9256                    }
9257    
9258                    return list;
9259            }
9260    
9261            /**
9262             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
9263             *
9264             * @param groupId the group ID
9265             * @param urlTitle the url title
9266             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9267             * @return the first matching journal article
9268             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9269             * @throws SystemException if a system exception occurred
9270             */
9271            public JournalArticle findByG_UT_First(long groupId, String urlTitle,
9272                    OrderByComparator orderByComparator)
9273                    throws NoSuchArticleException, SystemException {
9274                    JournalArticle journalArticle = fetchByG_UT_First(groupId, urlTitle,
9275                                    orderByComparator);
9276    
9277                    if (journalArticle != null) {
9278                            return journalArticle;
9279                    }
9280    
9281                    StringBundler msg = new StringBundler(6);
9282    
9283                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9284    
9285                    msg.append("groupId=");
9286                    msg.append(groupId);
9287    
9288                    msg.append(", urlTitle=");
9289                    msg.append(urlTitle);
9290    
9291                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9292    
9293                    throw new NoSuchArticleException(msg.toString());
9294            }
9295    
9296            /**
9297             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
9298             *
9299             * @param groupId the group ID
9300             * @param urlTitle the url title
9301             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9302             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
9303             * @throws SystemException if a system exception occurred
9304             */
9305            public JournalArticle fetchByG_UT_First(long groupId, String urlTitle,
9306                    OrderByComparator orderByComparator) throws SystemException {
9307                    List<JournalArticle> list = findByG_UT(groupId, urlTitle, 0, 1,
9308                                    orderByComparator);
9309    
9310                    if (!list.isEmpty()) {
9311                            return list.get(0);
9312                    }
9313    
9314                    return null;
9315            }
9316    
9317            /**
9318             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
9319             *
9320             * @param groupId the group ID
9321             * @param urlTitle the url title
9322             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9323             * @return the last matching journal article
9324             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9325             * @throws SystemException if a system exception occurred
9326             */
9327            public JournalArticle findByG_UT_Last(long groupId, String urlTitle,
9328                    OrderByComparator orderByComparator)
9329                    throws NoSuchArticleException, SystemException {
9330                    JournalArticle journalArticle = fetchByG_UT_Last(groupId, urlTitle,
9331                                    orderByComparator);
9332    
9333                    if (journalArticle != null) {
9334                            return journalArticle;
9335                    }
9336    
9337                    StringBundler msg = new StringBundler(6);
9338    
9339                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9340    
9341                    msg.append("groupId=");
9342                    msg.append(groupId);
9343    
9344                    msg.append(", urlTitle=");
9345                    msg.append(urlTitle);
9346    
9347                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9348    
9349                    throw new NoSuchArticleException(msg.toString());
9350            }
9351    
9352            /**
9353             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
9354             *
9355             * @param groupId the group ID
9356             * @param urlTitle the url title
9357             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9358             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
9359             * @throws SystemException if a system exception occurred
9360             */
9361            public JournalArticle fetchByG_UT_Last(long groupId, String urlTitle,
9362                    OrderByComparator orderByComparator) throws SystemException {
9363                    int count = countByG_UT(groupId, urlTitle);
9364    
9365                    List<JournalArticle> list = findByG_UT(groupId, urlTitle, count - 1,
9366                                    count, orderByComparator);
9367    
9368                    if (!list.isEmpty()) {
9369                            return list.get(0);
9370                    }
9371    
9372                    return null;
9373            }
9374    
9375            /**
9376             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
9377             *
9378             * @param id the primary key of the current journal article
9379             * @param groupId the group ID
9380             * @param urlTitle the url title
9381             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9382             * @return the previous, current, and next journal article
9383             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
9384             * @throws SystemException if a system exception occurred
9385             */
9386            public JournalArticle[] findByG_UT_PrevAndNext(long id, long groupId,
9387                    String urlTitle, OrderByComparator orderByComparator)
9388                    throws NoSuchArticleException, SystemException {
9389                    JournalArticle journalArticle = findByPrimaryKey(id);
9390    
9391                    Session session = null;
9392    
9393                    try {
9394                            session = openSession();
9395    
9396                            JournalArticle[] array = new JournalArticleImpl[3];
9397    
9398                            array[0] = getByG_UT_PrevAndNext(session, journalArticle, groupId,
9399                                            urlTitle, orderByComparator, true);
9400    
9401                            array[1] = journalArticle;
9402    
9403                            array[2] = getByG_UT_PrevAndNext(session, journalArticle, groupId,
9404                                            urlTitle, orderByComparator, false);
9405    
9406                            return array;
9407                    }
9408                    catch (Exception e) {
9409                            throw processException(e);
9410                    }
9411                    finally {
9412                            closeSession(session);
9413                    }
9414            }
9415    
9416            protected JournalArticle getByG_UT_PrevAndNext(Session session,
9417                    JournalArticle journalArticle, long groupId, String urlTitle,
9418                    OrderByComparator orderByComparator, boolean previous) {
9419                    StringBundler query = null;
9420    
9421                    if (orderByComparator != null) {
9422                            query = new StringBundler(6 +
9423                                            (orderByComparator.getOrderByFields().length * 6));
9424                    }
9425                    else {
9426                            query = new StringBundler(3);
9427                    }
9428    
9429                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9430    
9431                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
9432    
9433                    if (urlTitle == null) {
9434                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
9435                    }
9436                    else {
9437                            if (urlTitle.equals(StringPool.BLANK)) {
9438                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
9439                            }
9440                            else {
9441                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
9442                            }
9443                    }
9444    
9445                    if (orderByComparator != null) {
9446                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9447    
9448                            if (orderByConditionFields.length > 0) {
9449                                    query.append(WHERE_AND);
9450                            }
9451    
9452                            for (int i = 0; i < orderByConditionFields.length; i++) {
9453                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9454                                    query.append(orderByConditionFields[i]);
9455    
9456                                    if ((i + 1) < orderByConditionFields.length) {
9457                                            if (orderByComparator.isAscending() ^ previous) {
9458                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9459                                            }
9460                                            else {
9461                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9462                                            }
9463                                    }
9464                                    else {
9465                                            if (orderByComparator.isAscending() ^ previous) {
9466                                                    query.append(WHERE_GREATER_THAN);
9467                                            }
9468                                            else {
9469                                                    query.append(WHERE_LESSER_THAN);
9470                                            }
9471                                    }
9472                            }
9473    
9474                            query.append(ORDER_BY_CLAUSE);
9475    
9476                            String[] orderByFields = orderByComparator.getOrderByFields();
9477    
9478                            for (int i = 0; i < orderByFields.length; i++) {
9479                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9480                                    query.append(orderByFields[i]);
9481    
9482                                    if ((i + 1) < orderByFields.length) {
9483                                            if (orderByComparator.isAscending() ^ previous) {
9484                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9485                                            }
9486                                            else {
9487                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9488                                            }
9489                                    }
9490                                    else {
9491                                            if (orderByComparator.isAscending() ^ previous) {
9492                                                    query.append(ORDER_BY_ASC);
9493                                            }
9494                                            else {
9495                                                    query.append(ORDER_BY_DESC);
9496                                            }
9497                                    }
9498                            }
9499                    }
9500                    else {
9501                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9502                    }
9503    
9504                    String sql = query.toString();
9505    
9506                    Query q = session.createQuery(sql);
9507    
9508                    q.setFirstResult(0);
9509                    q.setMaxResults(2);
9510    
9511                    QueryPos qPos = QueryPos.getInstance(q);
9512    
9513                    qPos.add(groupId);
9514    
9515                    if (urlTitle != null) {
9516                            qPos.add(urlTitle);
9517                    }
9518    
9519                    if (orderByComparator != null) {
9520                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
9521    
9522                            for (Object value : values) {
9523                                    qPos.add(value);
9524                            }
9525                    }
9526    
9527                    List<JournalArticle> list = q.list();
9528    
9529                    if (list.size() == 2) {
9530                            return list.get(1);
9531                    }
9532                    else {
9533                            return null;
9534                    }
9535            }
9536    
9537            /**
9538             * Returns all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
9539             *
9540             * @param groupId the group ID
9541             * @param urlTitle the url title
9542             * @return the matching journal articles that the user has permission to view
9543             * @throws SystemException if a system exception occurred
9544             */
9545            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle)
9546                    throws SystemException {
9547                    return filterFindByG_UT(groupId, urlTitle, QueryUtil.ALL_POS,
9548                            QueryUtil.ALL_POS, null);
9549            }
9550    
9551            /**
9552             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
9553             *
9554             * <p>
9555             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9556             * </p>
9557             *
9558             * @param groupId the group ID
9559             * @param urlTitle the url title
9560             * @param start the lower bound of the range of journal articles
9561             * @param end the upper bound of the range of journal articles (not inclusive)
9562             * @return the range of matching journal articles that the user has permission to view
9563             * @throws SystemException if a system exception occurred
9564             */
9565            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle,
9566                    int start, int end) throws SystemException {
9567                    return filterFindByG_UT(groupId, urlTitle, start, end, null);
9568            }
9569    
9570            /**
9571             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and urlTitle = &#63;.
9572             *
9573             * <p>
9574             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9575             * </p>
9576             *
9577             * @param groupId the group ID
9578             * @param urlTitle the url title
9579             * @param start the lower bound of the range of journal articles
9580             * @param end the upper bound of the range of journal articles (not inclusive)
9581             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9582             * @return the ordered range of matching journal articles that the user has permission to view
9583             * @throws SystemException if a system exception occurred
9584             */
9585            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle,
9586                    int start, int end, OrderByComparator orderByComparator)
9587                    throws SystemException {
9588                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9589                            return findByG_UT(groupId, urlTitle, start, end, orderByComparator);
9590                    }
9591    
9592                    StringBundler query = null;
9593    
9594                    if (orderByComparator != null) {
9595                            query = new StringBundler(4 +
9596                                            (orderByComparator.getOrderByFields().length * 3));
9597                    }
9598                    else {
9599                            query = new StringBundler(4);
9600                    }
9601    
9602                    if (getDB().isSupportsInlineDistinct()) {
9603                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
9604                    }
9605                    else {
9606                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
9607                    }
9608    
9609                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
9610    
9611                    if (urlTitle == null) {
9612                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
9613                    }
9614                    else {
9615                            if (urlTitle.equals(StringPool.BLANK)) {
9616                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
9617                            }
9618                            else {
9619                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
9620                            }
9621                    }
9622    
9623                    if (!getDB().isSupportsInlineDistinct()) {
9624                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
9625                    }
9626    
9627                    if (orderByComparator != null) {
9628                            if (getDB().isSupportsInlineDistinct()) {
9629                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9630                                            orderByComparator);
9631                            }
9632                            else {
9633                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
9634                                            orderByComparator);
9635                            }
9636                    }
9637                    else {
9638                            if (getDB().isSupportsInlineDistinct()) {
9639                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9640                            }
9641                            else {
9642                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
9643                            }
9644                    }
9645    
9646                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9647                                    JournalArticle.class.getName(),
9648                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9649    
9650                    Session session = null;
9651    
9652                    try {
9653                            session = openSession();
9654    
9655                            SQLQuery q = session.createSQLQuery(sql);
9656    
9657                            if (getDB().isSupportsInlineDistinct()) {
9658                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
9659                            }
9660                            else {
9661                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
9662                            }
9663    
9664                            QueryPos qPos = QueryPos.getInstance(q);
9665    
9666                            qPos.add(groupId);
9667    
9668                            if (urlTitle != null) {
9669                                    qPos.add(urlTitle);
9670                            }
9671    
9672                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
9673                                    end);
9674                    }
9675                    catch (Exception e) {
9676                            throw processException(e);
9677                    }
9678                    finally {
9679                            closeSession(session);
9680                    }
9681            }
9682    
9683            /**
9684             * 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;.
9685             *
9686             * @param id the primary key of the current journal article
9687             * @param groupId the group ID
9688             * @param urlTitle the url title
9689             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9690             * @return the previous, current, and next journal article
9691             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
9692             * @throws SystemException if a system exception occurred
9693             */
9694            public JournalArticle[] filterFindByG_UT_PrevAndNext(long id, long groupId,
9695                    String urlTitle, OrderByComparator orderByComparator)
9696                    throws NoSuchArticleException, SystemException {
9697                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9698                            return findByG_UT_PrevAndNext(id, groupId, urlTitle,
9699                                    orderByComparator);
9700                    }
9701    
9702                    JournalArticle journalArticle = findByPrimaryKey(id);
9703    
9704                    Session session = null;
9705    
9706                    try {
9707                            session = openSession();
9708    
9709                            JournalArticle[] array = new JournalArticleImpl[3];
9710    
9711                            array[0] = filterGetByG_UT_PrevAndNext(session, journalArticle,
9712                                            groupId, urlTitle, orderByComparator, true);
9713    
9714                            array[1] = journalArticle;
9715    
9716                            array[2] = filterGetByG_UT_PrevAndNext(session, journalArticle,
9717                                            groupId, urlTitle, orderByComparator, false);
9718    
9719                            return array;
9720                    }
9721                    catch (Exception e) {
9722                            throw processException(e);
9723                    }
9724                    finally {
9725                            closeSession(session);
9726                    }
9727            }
9728    
9729            protected JournalArticle filterGetByG_UT_PrevAndNext(Session session,
9730                    JournalArticle journalArticle, long groupId, String urlTitle,
9731                    OrderByComparator orderByComparator, boolean previous) {
9732                    StringBundler query = null;
9733    
9734                    if (orderByComparator != null) {
9735                            query = new StringBundler(6 +
9736                                            (orderByComparator.getOrderByFields().length * 6));
9737                    }
9738                    else {
9739                            query = new StringBundler(3);
9740                    }
9741    
9742                    if (getDB().isSupportsInlineDistinct()) {
9743                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
9744                    }
9745                    else {
9746                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
9747                    }
9748    
9749                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
9750    
9751                    if (urlTitle == null) {
9752                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
9753                    }
9754                    else {
9755                            if (urlTitle.equals(StringPool.BLANK)) {
9756                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
9757                            }
9758                            else {
9759                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
9760                            }
9761                    }
9762    
9763                    if (!getDB().isSupportsInlineDistinct()) {
9764                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
9765                    }
9766    
9767                    if (orderByComparator != null) {
9768                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9769    
9770                            if (orderByConditionFields.length > 0) {
9771                                    query.append(WHERE_AND);
9772                            }
9773    
9774                            for (int i = 0; i < orderByConditionFields.length; i++) {
9775                                    if (getDB().isSupportsInlineDistinct()) {
9776                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9777                                    }
9778                                    else {
9779                                            query.append(_ORDER_BY_ENTITY_TABLE);
9780                                    }
9781    
9782                                    query.append(orderByConditionFields[i]);
9783    
9784                                    if ((i + 1) < orderByConditionFields.length) {
9785                                            if (orderByComparator.isAscending() ^ previous) {
9786                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9787                                            }
9788                                            else {
9789                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9790                                            }
9791                                    }
9792                                    else {
9793                                            if (orderByComparator.isAscending() ^ previous) {
9794                                                    query.append(WHERE_GREATER_THAN);
9795                                            }
9796                                            else {
9797                                                    query.append(WHERE_LESSER_THAN);
9798                                            }
9799                                    }
9800                            }
9801    
9802                            query.append(ORDER_BY_CLAUSE);
9803    
9804                            String[] orderByFields = orderByComparator.getOrderByFields();
9805    
9806                            for (int i = 0; i < orderByFields.length; i++) {
9807                                    if (getDB().isSupportsInlineDistinct()) {
9808                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9809                                    }
9810                                    else {
9811                                            query.append(_ORDER_BY_ENTITY_TABLE);
9812                                    }
9813    
9814                                    query.append(orderByFields[i]);
9815    
9816                                    if ((i + 1) < orderByFields.length) {
9817                                            if (orderByComparator.isAscending() ^ previous) {
9818                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9819                                            }
9820                                            else {
9821                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9822                                            }
9823                                    }
9824                                    else {
9825                                            if (orderByComparator.isAscending() ^ previous) {
9826                                                    query.append(ORDER_BY_ASC);
9827                                            }
9828                                            else {
9829                                                    query.append(ORDER_BY_DESC);
9830                                            }
9831                                    }
9832                            }
9833                    }
9834                    else {
9835                            if (getDB().isSupportsInlineDistinct()) {
9836                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9837                            }
9838                            else {
9839                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
9840                            }
9841                    }
9842    
9843                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9844                                    JournalArticle.class.getName(),
9845                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9846    
9847                    SQLQuery q = session.createSQLQuery(sql);
9848    
9849                    q.setFirstResult(0);
9850                    q.setMaxResults(2);
9851    
9852                    if (getDB().isSupportsInlineDistinct()) {
9853                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
9854                    }
9855                    else {
9856                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
9857                    }
9858    
9859                    QueryPos qPos = QueryPos.getInstance(q);
9860    
9861                    qPos.add(groupId);
9862    
9863                    if (urlTitle != null) {
9864                            qPos.add(urlTitle);
9865                    }
9866    
9867                    if (orderByComparator != null) {
9868                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
9869    
9870                            for (Object value : values) {
9871                                    qPos.add(value);
9872                            }
9873                    }
9874    
9875                    List<JournalArticle> list = q.list();
9876    
9877                    if (list.size() == 2) {
9878                            return list.get(1);
9879                    }
9880                    else {
9881                            return null;
9882                    }
9883            }
9884    
9885            /**
9886             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; from the database.
9887             *
9888             * @param groupId the group ID
9889             * @param urlTitle the url title
9890             * @throws SystemException if a system exception occurred
9891             */
9892            public void removeByG_UT(long groupId, String urlTitle)
9893                    throws SystemException {
9894                    for (JournalArticle journalArticle : findByG_UT(groupId, urlTitle,
9895                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
9896                            remove(journalArticle);
9897                    }
9898            }
9899    
9900            /**
9901             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63;.
9902             *
9903             * @param groupId the group ID
9904             * @param urlTitle the url title
9905             * @return the number of matching journal articles
9906             * @throws SystemException if a system exception occurred
9907             */
9908            public int countByG_UT(long groupId, String urlTitle)
9909                    throws SystemException {
9910                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_UT;
9911    
9912                    Object[] finderArgs = new Object[] { groupId, urlTitle };
9913    
9914                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
9915                                    this);
9916    
9917                    if (count == null) {
9918                            StringBundler query = new StringBundler(3);
9919    
9920                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
9921    
9922                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
9923    
9924                            if (urlTitle == null) {
9925                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
9926                            }
9927                            else {
9928                                    if (urlTitle.equals(StringPool.BLANK)) {
9929                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
9930                                    }
9931                                    else {
9932                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
9933                                    }
9934                            }
9935    
9936                            String sql = query.toString();
9937    
9938                            Session session = null;
9939    
9940                            try {
9941                                    session = openSession();
9942    
9943                                    Query q = session.createQuery(sql);
9944    
9945                                    QueryPos qPos = QueryPos.getInstance(q);
9946    
9947                                    qPos.add(groupId);
9948    
9949                                    if (urlTitle != null) {
9950                                            qPos.add(urlTitle);
9951                                    }
9952    
9953                                    count = (Long)q.uniqueResult();
9954    
9955                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
9956                            }
9957                            catch (Exception e) {
9958                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9959    
9960                                    throw processException(e);
9961                            }
9962                            finally {
9963                                    closeSession(session);
9964                            }
9965                    }
9966    
9967                    return count.intValue();
9968            }
9969    
9970            /**
9971             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
9972             *
9973             * @param groupId the group ID
9974             * @param urlTitle the url title
9975             * @return the number of matching journal articles that the user has permission to view
9976             * @throws SystemException if a system exception occurred
9977             */
9978            public int filterCountByG_UT(long groupId, String urlTitle)
9979                    throws SystemException {
9980                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9981                            return countByG_UT(groupId, urlTitle);
9982                    }
9983    
9984                    StringBundler query = new StringBundler(3);
9985    
9986                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
9987    
9988                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
9989    
9990                    if (urlTitle == null) {
9991                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
9992                    }
9993                    else {
9994                            if (urlTitle.equals(StringPool.BLANK)) {
9995                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
9996                            }
9997                            else {
9998                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
9999                            }
10000                    }
10001    
10002                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10003                                    JournalArticle.class.getName(),
10004                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10005    
10006                    Session session = null;
10007    
10008                    try {
10009                            session = openSession();
10010    
10011                            SQLQuery q = session.createSQLQuery(sql);
10012    
10013                            q.addScalar(COUNT_COLUMN_NAME,
10014                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
10015    
10016                            QueryPos qPos = QueryPos.getInstance(q);
10017    
10018                            qPos.add(groupId);
10019    
10020                            if (urlTitle != null) {
10021                                    qPos.add(urlTitle);
10022                            }
10023    
10024                            Long count = (Long)q.uniqueResult();
10025    
10026                            return count.intValue();
10027                    }
10028                    catch (Exception e) {
10029                            throw processException(e);
10030                    }
10031                    finally {
10032                            closeSession(session);
10033                    }
10034            }
10035    
10036            private static final String _FINDER_COLUMN_G_UT_GROUPID_2 = "journalArticle.groupId = ? AND ";
10037            private static final String _FINDER_COLUMN_G_UT_URLTITLE_1 = "journalArticle.urlTitle IS NULL";
10038            private static final String _FINDER_COLUMN_G_UT_URLTITLE_2 = "journalArticle.urlTitle = ?";
10039            private static final String _FINDER_COLUMN_G_UT_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = ?)";
10040            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
10041                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
10042                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
10043                            "findByG_S",
10044                            new String[] {
10045                                    Long.class.getName(), String.class.getName(),
10046                                    
10047                            Integer.class.getName(), Integer.class.getName(),
10048                                    OrderByComparator.class.getName()
10049                            });
10050            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
10051                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
10052                            JournalArticleImpl.class,
10053                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
10054                            new String[] { Long.class.getName(), String.class.getName() },
10055                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
10056                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK |
10057                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
10058                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
10059            public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
10060                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
10061                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
10062                            new String[] { Long.class.getName(), String.class.getName() });
10063    
10064            /**
10065             * Returns all the journal articles where groupId = &#63; and structureId = &#63;.
10066             *
10067             * @param groupId the group ID
10068             * @param structureId the structure ID
10069             * @return the matching journal articles
10070             * @throws SystemException if a system exception occurred
10071             */
10072            public List<JournalArticle> findByG_S(long groupId, String structureId)
10073                    throws SystemException {
10074                    return findByG_S(groupId, structureId, QueryUtil.ALL_POS,
10075                            QueryUtil.ALL_POS, null);
10076            }
10077    
10078            /**
10079             * Returns a range of all the journal articles where groupId = &#63; and structureId = &#63;.
10080             *
10081             * <p>
10082             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10083             * </p>
10084             *
10085             * @param groupId the group ID
10086             * @param structureId the structure ID
10087             * @param start the lower bound of the range of journal articles
10088             * @param end the upper bound of the range of journal articles (not inclusive)
10089             * @return the range of matching journal articles
10090             * @throws SystemException if a system exception occurred
10091             */
10092            public List<JournalArticle> findByG_S(long groupId, String structureId,
10093                    int start, int end) throws SystemException {
10094                    return findByG_S(groupId, structureId, start, end, null);
10095            }
10096    
10097            /**
10098             * Returns an ordered range of all the journal articles where groupId = &#63; and structureId = &#63;.
10099             *
10100             * <p>
10101             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10102             * </p>
10103             *
10104             * @param groupId the group ID
10105             * @param structureId the structure ID
10106             * @param start the lower bound of the range of journal articles
10107             * @param end the upper bound of the range of journal articles (not inclusive)
10108             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10109             * @return the ordered range of matching journal articles
10110             * @throws SystemException if a system exception occurred
10111             */
10112            public List<JournalArticle> findByG_S(long groupId, String structureId,
10113                    int start, int end, OrderByComparator orderByComparator)
10114                    throws SystemException {
10115                    boolean pagination = true;
10116                    FinderPath finderPath = null;
10117                    Object[] finderArgs = null;
10118    
10119                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10120                                    (orderByComparator == null)) {
10121                            pagination = false;
10122                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
10123                            finderArgs = new Object[] { groupId, structureId };
10124                    }
10125                    else {
10126                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
10127                            finderArgs = new Object[] {
10128                                            groupId, structureId,
10129                                            
10130                                            start, end, orderByComparator
10131                                    };
10132                    }
10133    
10134                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
10135                                    finderArgs, this);
10136    
10137                    if ((list != null) && !list.isEmpty()) {
10138                            for (JournalArticle journalArticle : list) {
10139                                    if ((groupId != journalArticle.getGroupId()) ||
10140                                                    !Validator.equals(structureId,
10141                                                            journalArticle.getStructureId())) {
10142                                            list = null;
10143    
10144                                            break;
10145                                    }
10146                            }
10147                    }
10148    
10149                    if (list == null) {
10150                            StringBundler query = null;
10151    
10152                            if (orderByComparator != null) {
10153                                    query = new StringBundler(4 +
10154                                                    (orderByComparator.getOrderByFields().length * 3));
10155                            }
10156                            else {
10157                                    query = new StringBundler(4);
10158                            }
10159    
10160                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10161    
10162                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
10163    
10164                            if (structureId == null) {
10165                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
10166                            }
10167                            else {
10168                                    if (structureId.equals(StringPool.BLANK)) {
10169                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
10170                                    }
10171                                    else {
10172                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
10173                                    }
10174                            }
10175    
10176                            if (orderByComparator != null) {
10177                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10178                                            orderByComparator);
10179                            }
10180                            else
10181                             if (pagination) {
10182                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10183                            }
10184    
10185                            String sql = query.toString();
10186    
10187                            Session session = null;
10188    
10189                            try {
10190                                    session = openSession();
10191    
10192                                    Query q = session.createQuery(sql);
10193    
10194                                    QueryPos qPos = QueryPos.getInstance(q);
10195    
10196                                    qPos.add(groupId);
10197    
10198                                    if (structureId != null) {
10199                                            qPos.add(structureId);
10200                                    }
10201    
10202                                    if (!pagination) {
10203                                            list = (List<JournalArticle>)QueryUtil.list(q,
10204                                                            getDialect(), start, end, false);
10205    
10206                                            Collections.sort(list);
10207    
10208                                            list = new UnmodifiableList<JournalArticle>(list);
10209                                    }
10210                                    else {
10211                                            list = (List<JournalArticle>)QueryUtil.list(q,
10212                                                            getDialect(), start, end);
10213                                    }
10214    
10215                                    cacheResult(list);
10216    
10217                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
10218                            }
10219                            catch (Exception e) {
10220                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10221    
10222                                    throw processException(e);
10223                            }
10224                            finally {
10225                                    closeSession(session);
10226                            }
10227                    }
10228    
10229                    return list;
10230            }
10231    
10232            /**
10233             * Returns the first journal article in the ordered set where groupId = &#63; and structureId = &#63;.
10234             *
10235             * @param groupId the group ID
10236             * @param structureId the structure ID
10237             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10238             * @return the first matching journal article
10239             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10240             * @throws SystemException if a system exception occurred
10241             */
10242            public JournalArticle findByG_S_First(long groupId, String structureId,
10243                    OrderByComparator orderByComparator)
10244                    throws NoSuchArticleException, SystemException {
10245                    JournalArticle journalArticle = fetchByG_S_First(groupId, structureId,
10246                                    orderByComparator);
10247    
10248                    if (journalArticle != null) {
10249                            return journalArticle;
10250                    }
10251    
10252                    StringBundler msg = new StringBundler(6);
10253    
10254                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10255    
10256                    msg.append("groupId=");
10257                    msg.append(groupId);
10258    
10259                    msg.append(", structureId=");
10260                    msg.append(structureId);
10261    
10262                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10263    
10264                    throw new NoSuchArticleException(msg.toString());
10265            }
10266    
10267            /**
10268             * Returns the first journal article in the ordered set where groupId = &#63; and structureId = &#63;.
10269             *
10270             * @param groupId the group ID
10271             * @param structureId the structure ID
10272             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10273             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
10274             * @throws SystemException if a system exception occurred
10275             */
10276            public JournalArticle fetchByG_S_First(long groupId, String structureId,
10277                    OrderByComparator orderByComparator) throws SystemException {
10278                    List<JournalArticle> list = findByG_S(groupId, structureId, 0, 1,
10279                                    orderByComparator);
10280    
10281                    if (!list.isEmpty()) {
10282                            return list.get(0);
10283                    }
10284    
10285                    return null;
10286            }
10287    
10288            /**
10289             * Returns the last journal article in the ordered set where groupId = &#63; and structureId = &#63;.
10290             *
10291             * @param groupId the group ID
10292             * @param structureId the structure ID
10293             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10294             * @return the last matching journal article
10295             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10296             * @throws SystemException if a system exception occurred
10297             */
10298            public JournalArticle findByG_S_Last(long groupId, String structureId,
10299                    OrderByComparator orderByComparator)
10300                    throws NoSuchArticleException, SystemException {
10301                    JournalArticle journalArticle = fetchByG_S_Last(groupId, structureId,
10302                                    orderByComparator);
10303    
10304                    if (journalArticle != null) {
10305                            return journalArticle;
10306                    }
10307    
10308                    StringBundler msg = new StringBundler(6);
10309    
10310                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10311    
10312                    msg.append("groupId=");
10313                    msg.append(groupId);
10314    
10315                    msg.append(", structureId=");
10316                    msg.append(structureId);
10317    
10318                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10319    
10320                    throw new NoSuchArticleException(msg.toString());
10321            }
10322    
10323            /**
10324             * Returns the last journal article in the ordered set where groupId = &#63; and structureId = &#63;.
10325             *
10326             * @param groupId the group ID
10327             * @param structureId the structure ID
10328             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10329             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
10330             * @throws SystemException if a system exception occurred
10331             */
10332            public JournalArticle fetchByG_S_Last(long groupId, String structureId,
10333                    OrderByComparator orderByComparator) throws SystemException {
10334                    int count = countByG_S(groupId, structureId);
10335    
10336                    List<JournalArticle> list = findByG_S(groupId, structureId, count - 1,
10337                                    count, orderByComparator);
10338    
10339                    if (!list.isEmpty()) {
10340                            return list.get(0);
10341                    }
10342    
10343                    return null;
10344            }
10345    
10346            /**
10347             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and structureId = &#63;.
10348             *
10349             * @param id the primary key of the current journal article
10350             * @param groupId the group ID
10351             * @param structureId the structure ID
10352             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10353             * @return the previous, current, and next journal article
10354             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
10355             * @throws SystemException if a system exception occurred
10356             */
10357            public JournalArticle[] findByG_S_PrevAndNext(long id, long groupId,
10358                    String structureId, OrderByComparator orderByComparator)
10359                    throws NoSuchArticleException, SystemException {
10360                    JournalArticle journalArticle = findByPrimaryKey(id);
10361    
10362                    Session session = null;
10363    
10364                    try {
10365                            session = openSession();
10366    
10367                            JournalArticle[] array = new JournalArticleImpl[3];
10368    
10369                            array[0] = getByG_S_PrevAndNext(session, journalArticle, groupId,
10370                                            structureId, orderByComparator, true);
10371    
10372                            array[1] = journalArticle;
10373    
10374                            array[2] = getByG_S_PrevAndNext(session, journalArticle, groupId,
10375                                            structureId, orderByComparator, false);
10376    
10377                            return array;
10378                    }
10379                    catch (Exception e) {
10380                            throw processException(e);
10381                    }
10382                    finally {
10383                            closeSession(session);
10384                    }
10385            }
10386    
10387            protected JournalArticle getByG_S_PrevAndNext(Session session,
10388                    JournalArticle journalArticle, long groupId, String structureId,
10389                    OrderByComparator orderByComparator, boolean previous) {
10390                    StringBundler query = null;
10391    
10392                    if (orderByComparator != null) {
10393                            query = new StringBundler(6 +
10394                                            (orderByComparator.getOrderByFields().length * 6));
10395                    }
10396                    else {
10397                            query = new StringBundler(3);
10398                    }
10399    
10400                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10401    
10402                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
10403    
10404                    if (structureId == null) {
10405                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
10406                    }
10407                    else {
10408                            if (structureId.equals(StringPool.BLANK)) {
10409                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
10410                            }
10411                            else {
10412                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
10413                            }
10414                    }
10415    
10416                    if (orderByComparator != null) {
10417                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10418    
10419                            if (orderByConditionFields.length > 0) {
10420                                    query.append(WHERE_AND);
10421                            }
10422    
10423                            for (int i = 0; i < orderByConditionFields.length; i++) {
10424                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10425                                    query.append(orderByConditionFields[i]);
10426    
10427                                    if ((i + 1) < orderByConditionFields.length) {
10428                                            if (orderByComparator.isAscending() ^ previous) {
10429                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10430                                            }
10431                                            else {
10432                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10433                                            }
10434                                    }
10435                                    else {
10436                                            if (orderByComparator.isAscending() ^ previous) {
10437                                                    query.append(WHERE_GREATER_THAN);
10438                                            }
10439                                            else {
10440                                                    query.append(WHERE_LESSER_THAN);
10441                                            }
10442                                    }
10443                            }
10444    
10445                            query.append(ORDER_BY_CLAUSE);
10446    
10447                            String[] orderByFields = orderByComparator.getOrderByFields();
10448    
10449                            for (int i = 0; i < orderByFields.length; i++) {
10450                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10451                                    query.append(orderByFields[i]);
10452    
10453                                    if ((i + 1) < orderByFields.length) {
10454                                            if (orderByComparator.isAscending() ^ previous) {
10455                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10456                                            }
10457                                            else {
10458                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10459                                            }
10460                                    }
10461                                    else {
10462                                            if (orderByComparator.isAscending() ^ previous) {
10463                                                    query.append(ORDER_BY_ASC);
10464                                            }
10465                                            else {
10466                                                    query.append(ORDER_BY_DESC);
10467                                            }
10468                                    }
10469                            }
10470                    }
10471                    else {
10472                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10473                    }
10474    
10475                    String sql = query.toString();
10476    
10477                    Query q = session.createQuery(sql);
10478    
10479                    q.setFirstResult(0);
10480                    q.setMaxResults(2);
10481    
10482                    QueryPos qPos = QueryPos.getInstance(q);
10483    
10484                    qPos.add(groupId);
10485    
10486                    if (structureId != null) {
10487                            qPos.add(structureId);
10488                    }
10489    
10490                    if (orderByComparator != null) {
10491                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
10492    
10493                            for (Object value : values) {
10494                                    qPos.add(value);
10495                            }
10496                    }
10497    
10498                    List<JournalArticle> list = q.list();
10499    
10500                    if (list.size() == 2) {
10501                            return list.get(1);
10502                    }
10503                    else {
10504                            return null;
10505                    }
10506            }
10507    
10508            /**
10509             * Returns all the journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
10510             *
10511             * @param groupId the group ID
10512             * @param structureId the structure ID
10513             * @return the matching journal articles that the user has permission to view
10514             * @throws SystemException if a system exception occurred
10515             */
10516            public List<JournalArticle> filterFindByG_S(long groupId, String structureId)
10517                    throws SystemException {
10518                    return filterFindByG_S(groupId, structureId, QueryUtil.ALL_POS,
10519                            QueryUtil.ALL_POS, null);
10520            }
10521    
10522            /**
10523             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
10524             *
10525             * <p>
10526             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10527             * </p>
10528             *
10529             * @param groupId the group ID
10530             * @param structureId the structure ID
10531             * @param start the lower bound of the range of journal articles
10532             * @param end the upper bound of the range of journal articles (not inclusive)
10533             * @return the range of matching journal articles that the user has permission to view
10534             * @throws SystemException if a system exception occurred
10535             */
10536            public List<JournalArticle> filterFindByG_S(long groupId,
10537                    String structureId, int start, int end) throws SystemException {
10538                    return filterFindByG_S(groupId, structureId, start, end, null);
10539            }
10540    
10541            /**
10542             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and structureId = &#63;.
10543             *
10544             * <p>
10545             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10546             * </p>
10547             *
10548             * @param groupId the group ID
10549             * @param structureId the structure ID
10550             * @param start the lower bound of the range of journal articles
10551             * @param end the upper bound of the range of journal articles (not inclusive)
10552             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10553             * @return the ordered range of matching journal articles that the user has permission to view
10554             * @throws SystemException if a system exception occurred
10555             */
10556            public List<JournalArticle> filterFindByG_S(long groupId,
10557                    String structureId, int start, int end,
10558                    OrderByComparator orderByComparator) throws SystemException {
10559                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10560                            return findByG_S(groupId, structureId, start, end, orderByComparator);
10561                    }
10562    
10563                    StringBundler query = null;
10564    
10565                    if (orderByComparator != null) {
10566                            query = new StringBundler(4 +
10567                                            (orderByComparator.getOrderByFields().length * 3));
10568                    }
10569                    else {
10570                            query = new StringBundler(4);
10571                    }
10572    
10573                    if (getDB().isSupportsInlineDistinct()) {
10574                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
10575                    }
10576                    else {
10577                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
10578                    }
10579    
10580                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
10581    
10582                    if (structureId == null) {
10583                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
10584                    }
10585                    else {
10586                            if (structureId.equals(StringPool.BLANK)) {
10587                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
10588                            }
10589                            else {
10590                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
10591                            }
10592                    }
10593    
10594                    if (!getDB().isSupportsInlineDistinct()) {
10595                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
10596                    }
10597    
10598                    if (orderByComparator != null) {
10599                            if (getDB().isSupportsInlineDistinct()) {
10600                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10601                                            orderByComparator);
10602                            }
10603                            else {
10604                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10605                                            orderByComparator);
10606                            }
10607                    }
10608                    else {
10609                            if (getDB().isSupportsInlineDistinct()) {
10610                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10611                            }
10612                            else {
10613                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
10614                            }
10615                    }
10616    
10617                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10618                                    JournalArticle.class.getName(),
10619                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10620    
10621                    Session session = null;
10622    
10623                    try {
10624                            session = openSession();
10625    
10626                            SQLQuery q = session.createSQLQuery(sql);
10627    
10628                            if (getDB().isSupportsInlineDistinct()) {
10629                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
10630                            }
10631                            else {
10632                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
10633                            }
10634    
10635                            QueryPos qPos = QueryPos.getInstance(q);
10636    
10637                            qPos.add(groupId);
10638    
10639                            if (structureId != null) {
10640                                    qPos.add(structureId);
10641                            }
10642    
10643                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
10644                                    end);
10645                    }
10646                    catch (Exception e) {
10647                            throw processException(e);
10648                    }
10649                    finally {
10650                            closeSession(session);
10651                    }
10652            }
10653    
10654            /**
10655             * 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;.
10656             *
10657             * @param id the primary key of the current journal article
10658             * @param groupId the group ID
10659             * @param structureId the structure ID
10660             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10661             * @return the previous, current, and next journal article
10662             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
10663             * @throws SystemException if a system exception occurred
10664             */
10665            public JournalArticle[] filterFindByG_S_PrevAndNext(long id, long groupId,
10666                    String structureId, OrderByComparator orderByComparator)
10667                    throws NoSuchArticleException, SystemException {
10668                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10669                            return findByG_S_PrevAndNext(id, groupId, structureId,
10670                                    orderByComparator);
10671                    }
10672    
10673                    JournalArticle journalArticle = findByPrimaryKey(id);
10674    
10675                    Session session = null;
10676    
10677                    try {
10678                            session = openSession();
10679    
10680                            JournalArticle[] array = new JournalArticleImpl[3];
10681    
10682                            array[0] = filterGetByG_S_PrevAndNext(session, journalArticle,
10683                                            groupId, structureId, orderByComparator, true);
10684    
10685                            array[1] = journalArticle;
10686    
10687                            array[2] = filterGetByG_S_PrevAndNext(session, journalArticle,
10688                                            groupId, structureId, orderByComparator, false);
10689    
10690                            return array;
10691                    }
10692                    catch (Exception e) {
10693                            throw processException(e);
10694                    }
10695                    finally {
10696                            closeSession(session);
10697                    }
10698            }
10699    
10700            protected JournalArticle filterGetByG_S_PrevAndNext(Session session,
10701                    JournalArticle journalArticle, long groupId, String structureId,
10702                    OrderByComparator orderByComparator, boolean previous) {
10703                    StringBundler query = null;
10704    
10705                    if (orderByComparator != null) {
10706                            query = new StringBundler(6 +
10707                                            (orderByComparator.getOrderByFields().length * 6));
10708                    }
10709                    else {
10710                            query = new StringBundler(3);
10711                    }
10712    
10713                    if (getDB().isSupportsInlineDistinct()) {
10714                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
10715                    }
10716                    else {
10717                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
10718                    }
10719    
10720                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
10721    
10722                    if (structureId == null) {
10723                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
10724                    }
10725                    else {
10726                            if (structureId.equals(StringPool.BLANK)) {
10727                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
10728                            }
10729                            else {
10730                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
10731                            }
10732                    }
10733    
10734                    if (!getDB().isSupportsInlineDistinct()) {
10735                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
10736                    }
10737    
10738                    if (orderByComparator != null) {
10739                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10740    
10741                            if (orderByConditionFields.length > 0) {
10742                                    query.append(WHERE_AND);
10743                            }
10744    
10745                            for (int i = 0; i < orderByConditionFields.length; i++) {
10746                                    if (getDB().isSupportsInlineDistinct()) {
10747                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10748                                    }
10749                                    else {
10750                                            query.append(_ORDER_BY_ENTITY_TABLE);
10751                                    }
10752    
10753                                    query.append(orderByConditionFields[i]);
10754    
10755                                    if ((i + 1) < orderByConditionFields.length) {
10756                                            if (orderByComparator.isAscending() ^ previous) {
10757                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10758                                            }
10759                                            else {
10760                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10761                                            }
10762                                    }
10763                                    else {
10764                                            if (orderByComparator.isAscending() ^ previous) {
10765                                                    query.append(WHERE_GREATER_THAN);
10766                                            }
10767                                            else {
10768                                                    query.append(WHERE_LESSER_THAN);
10769                                            }
10770                                    }
10771                            }
10772    
10773                            query.append(ORDER_BY_CLAUSE);
10774    
10775                            String[] orderByFields = orderByComparator.getOrderByFields();
10776    
10777                            for (int i = 0; i < orderByFields.length; i++) {
10778                                    if (getDB().isSupportsInlineDistinct()) {
10779                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10780                                    }
10781                                    else {
10782                                            query.append(_ORDER_BY_ENTITY_TABLE);
10783                                    }
10784    
10785                                    query.append(orderByFields[i]);
10786    
10787                                    if ((i + 1) < orderByFields.length) {
10788                                            if (orderByComparator.isAscending() ^ previous) {
10789                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10790                                            }
10791                                            else {
10792                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10793                                            }
10794                                    }
10795                                    else {
10796                                            if (orderByComparator.isAscending() ^ previous) {
10797                                                    query.append(ORDER_BY_ASC);
10798                                            }
10799                                            else {
10800                                                    query.append(ORDER_BY_DESC);
10801                                            }
10802                                    }
10803                            }
10804                    }
10805                    else {
10806                            if (getDB().isSupportsInlineDistinct()) {
10807                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10808                            }
10809                            else {
10810                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
10811                            }
10812                    }
10813    
10814                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10815                                    JournalArticle.class.getName(),
10816                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10817    
10818                    SQLQuery q = session.createSQLQuery(sql);
10819    
10820                    q.setFirstResult(0);
10821                    q.setMaxResults(2);
10822    
10823                    if (getDB().isSupportsInlineDistinct()) {
10824                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
10825                    }
10826                    else {
10827                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
10828                    }
10829    
10830                    QueryPos qPos = QueryPos.getInstance(q);
10831    
10832                    qPos.add(groupId);
10833    
10834                    if (structureId != null) {
10835                            qPos.add(structureId);
10836                    }
10837    
10838                    if (orderByComparator != null) {
10839                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
10840    
10841                            for (Object value : values) {
10842                                    qPos.add(value);
10843                            }
10844                    }
10845    
10846                    List<JournalArticle> list = q.list();
10847    
10848                    if (list.size() == 2) {
10849                            return list.get(1);
10850                    }
10851                    else {
10852                            return null;
10853                    }
10854            }
10855    
10856            /**
10857             * Removes all the journal articles where groupId = &#63; and structureId = &#63; from the database.
10858             *
10859             * @param groupId the group ID
10860             * @param structureId the structure ID
10861             * @throws SystemException if a system exception occurred
10862             */
10863            public void removeByG_S(long groupId, String structureId)
10864                    throws SystemException {
10865                    for (JournalArticle journalArticle : findByG_S(groupId, structureId,
10866                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10867                            remove(journalArticle);
10868                    }
10869            }
10870    
10871            /**
10872             * Returns the number of journal articles where groupId = &#63; and structureId = &#63;.
10873             *
10874             * @param groupId the group ID
10875             * @param structureId the structure ID
10876             * @return the number of matching journal articles
10877             * @throws SystemException if a system exception occurred
10878             */
10879            public int countByG_S(long groupId, String structureId)
10880                    throws SystemException {
10881                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_S;
10882    
10883                    Object[] finderArgs = new Object[] { groupId, structureId };
10884    
10885                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
10886                                    this);
10887    
10888                    if (count == null) {
10889                            StringBundler query = new StringBundler(3);
10890    
10891                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
10892    
10893                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
10894    
10895                            if (structureId == null) {
10896                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
10897                            }
10898                            else {
10899                                    if (structureId.equals(StringPool.BLANK)) {
10900                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
10901                                    }
10902                                    else {
10903                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
10904                                    }
10905                            }
10906    
10907                            String sql = query.toString();
10908    
10909                            Session session = null;
10910    
10911                            try {
10912                                    session = openSession();
10913    
10914                                    Query q = session.createQuery(sql);
10915    
10916                                    QueryPos qPos = QueryPos.getInstance(q);
10917    
10918                                    qPos.add(groupId);
10919    
10920                                    if (structureId != null) {
10921                                            qPos.add(structureId);
10922                                    }
10923    
10924                                    count = (Long)q.uniqueResult();
10925    
10926                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
10927                            }
10928                            catch (Exception e) {
10929                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10930    
10931                                    throw processException(e);
10932                            }
10933                            finally {
10934                                    closeSession(session);
10935                            }
10936                    }
10937    
10938                    return count.intValue();
10939            }
10940    
10941            /**
10942             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
10943             *
10944             * @param groupId the group ID
10945             * @param structureId the structure ID
10946             * @return the number of matching journal articles that the user has permission to view
10947             * @throws SystemException if a system exception occurred
10948             */
10949            public int filterCountByG_S(long groupId, String structureId)
10950                    throws SystemException {
10951                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10952                            return countByG_S(groupId, structureId);
10953                    }
10954    
10955                    StringBundler query = new StringBundler(3);
10956    
10957                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
10958    
10959                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
10960    
10961                    if (structureId == null) {
10962                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
10963                    }
10964                    else {
10965                            if (structureId.equals(StringPool.BLANK)) {
10966                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
10967                            }
10968                            else {
10969                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
10970                            }
10971                    }
10972    
10973                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10974                                    JournalArticle.class.getName(),
10975                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10976    
10977                    Session session = null;
10978    
10979                    try {
10980                            session = openSession();
10981    
10982                            SQLQuery q = session.createSQLQuery(sql);
10983    
10984                            q.addScalar(COUNT_COLUMN_NAME,
10985                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
10986    
10987                            QueryPos qPos = QueryPos.getInstance(q);
10988    
10989                            qPos.add(groupId);
10990    
10991                            if (structureId != null) {
10992                                    qPos.add(structureId);
10993                            }
10994    
10995                            Long count = (Long)q.uniqueResult();
10996    
10997                            return count.intValue();
10998                    }
10999                    catch (Exception e) {
11000                            throw processException(e);
11001                    }
11002                    finally {
11003                            closeSession(session);
11004                    }
11005            }
11006    
11007            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
11008            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
11009            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
11010            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = ?)";
11011            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
11012                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
11013                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
11014                            "findByG_T",
11015                            new String[] {
11016                                    Long.class.getName(), String.class.getName(),
11017                                    
11018                            Integer.class.getName(), Integer.class.getName(),
11019                                    OrderByComparator.class.getName()
11020                            });
11021            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
11022                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
11023                            JournalArticleImpl.class,
11024                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_T",
11025                            new String[] { Long.class.getName(), String.class.getName() },
11026                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
11027                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK |
11028                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
11029                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
11030            public static final FinderPath FINDER_PATH_COUNT_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
11031                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
11032                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_T",
11033                            new String[] { Long.class.getName(), String.class.getName() });
11034    
11035            /**
11036             * Returns all the journal articles where groupId = &#63; and templateId = &#63;.
11037             *
11038             * @param groupId the group ID
11039             * @param templateId the template ID
11040             * @return the matching journal articles
11041             * @throws SystemException if a system exception occurred
11042             */
11043            public List<JournalArticle> findByG_T(long groupId, String templateId)
11044                    throws SystemException {
11045                    return findByG_T(groupId, templateId, QueryUtil.ALL_POS,
11046                            QueryUtil.ALL_POS, null);
11047            }
11048    
11049            /**
11050             * Returns a range of all the journal articles where groupId = &#63; and templateId = &#63;.
11051             *
11052             * <p>
11053             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11054             * </p>
11055             *
11056             * @param groupId the group ID
11057             * @param templateId the template ID
11058             * @param start the lower bound of the range of journal articles
11059             * @param end the upper bound of the range of journal articles (not inclusive)
11060             * @return the range of matching journal articles
11061             * @throws SystemException if a system exception occurred
11062             */
11063            public List<JournalArticle> findByG_T(long groupId, String templateId,
11064                    int start, int end) throws SystemException {
11065                    return findByG_T(groupId, templateId, start, end, null);
11066            }
11067    
11068            /**
11069             * Returns an ordered range of all the journal articles where groupId = &#63; and templateId = &#63;.
11070             *
11071             * <p>
11072             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11073             * </p>
11074             *
11075             * @param groupId the group ID
11076             * @param templateId the template ID
11077             * @param start the lower bound of the range of journal articles
11078             * @param end the upper bound of the range of journal articles (not inclusive)
11079             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11080             * @return the ordered range of matching journal articles
11081             * @throws SystemException if a system exception occurred
11082             */
11083            public List<JournalArticle> findByG_T(long groupId, String templateId,
11084                    int start, int end, OrderByComparator orderByComparator)
11085                    throws SystemException {
11086                    boolean pagination = true;
11087                    FinderPath finderPath = null;
11088                    Object[] finderArgs = null;
11089    
11090                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11091                                    (orderByComparator == null)) {
11092                            pagination = false;
11093                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T;
11094                            finderArgs = new Object[] { groupId, templateId };
11095                    }
11096                    else {
11097                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_T;
11098                            finderArgs = new Object[] {
11099                                            groupId, templateId,
11100                                            
11101                                            start, end, orderByComparator
11102                                    };
11103                    }
11104    
11105                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
11106                                    finderArgs, this);
11107    
11108                    if ((list != null) && !list.isEmpty()) {
11109                            for (JournalArticle journalArticle : list) {
11110                                    if ((groupId != journalArticle.getGroupId()) ||
11111                                                    !Validator.equals(templateId,
11112                                                            journalArticle.getTemplateId())) {
11113                                            list = null;
11114    
11115                                            break;
11116                                    }
11117                            }
11118                    }
11119    
11120                    if (list == null) {
11121                            StringBundler query = null;
11122    
11123                            if (orderByComparator != null) {
11124                                    query = new StringBundler(4 +
11125                                                    (orderByComparator.getOrderByFields().length * 3));
11126                            }
11127                            else {
11128                                    query = new StringBundler(4);
11129                            }
11130    
11131                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11132    
11133                            query.append(_FINDER_COLUMN_G_T_GROUPID_2);
11134    
11135                            if (templateId == null) {
11136                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
11137                            }
11138                            else {
11139                                    if (templateId.equals(StringPool.BLANK)) {
11140                                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
11141                                    }
11142                                    else {
11143                                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
11144                                    }
11145                            }
11146    
11147                            if (orderByComparator != null) {
11148                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11149                                            orderByComparator);
11150                            }
11151                            else
11152                             if (pagination) {
11153                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11154                            }
11155    
11156                            String sql = query.toString();
11157    
11158                            Session session = null;
11159    
11160                            try {
11161                                    session = openSession();
11162    
11163                                    Query q = session.createQuery(sql);
11164    
11165                                    QueryPos qPos = QueryPos.getInstance(q);
11166    
11167                                    qPos.add(groupId);
11168    
11169                                    if (templateId != null) {
11170                                            qPos.add(templateId);
11171                                    }
11172    
11173                                    if (!pagination) {
11174                                            list = (List<JournalArticle>)QueryUtil.list(q,
11175                                                            getDialect(), start, end, false);
11176    
11177                                            Collections.sort(list);
11178    
11179                                            list = new UnmodifiableList<JournalArticle>(list);
11180                                    }
11181                                    else {
11182                                            list = (List<JournalArticle>)QueryUtil.list(q,
11183                                                            getDialect(), start, end);
11184                                    }
11185    
11186                                    cacheResult(list);
11187    
11188                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
11189                            }
11190                            catch (Exception e) {
11191                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11192    
11193                                    throw processException(e);
11194                            }
11195                            finally {
11196                                    closeSession(session);
11197                            }
11198                    }
11199    
11200                    return list;
11201            }
11202    
11203            /**
11204             * Returns the first journal article in the ordered set where groupId = &#63; and templateId = &#63;.
11205             *
11206             * @param groupId the group ID
11207             * @param templateId the template ID
11208             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11209             * @return the first matching journal article
11210             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11211             * @throws SystemException if a system exception occurred
11212             */
11213            public JournalArticle findByG_T_First(long groupId, String templateId,
11214                    OrderByComparator orderByComparator)
11215                    throws NoSuchArticleException, SystemException {
11216                    JournalArticle journalArticle = fetchByG_T_First(groupId, templateId,
11217                                    orderByComparator);
11218    
11219                    if (journalArticle != null) {
11220                            return journalArticle;
11221                    }
11222    
11223                    StringBundler msg = new StringBundler(6);
11224    
11225                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11226    
11227                    msg.append("groupId=");
11228                    msg.append(groupId);
11229    
11230                    msg.append(", templateId=");
11231                    msg.append(templateId);
11232    
11233                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11234    
11235                    throw new NoSuchArticleException(msg.toString());
11236            }
11237    
11238            /**
11239             * Returns the first journal article in the ordered set where groupId = &#63; and templateId = &#63;.
11240             *
11241             * @param groupId the group ID
11242             * @param templateId the template ID
11243             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11244             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
11245             * @throws SystemException if a system exception occurred
11246             */
11247            public JournalArticle fetchByG_T_First(long groupId, String templateId,
11248                    OrderByComparator orderByComparator) throws SystemException {
11249                    List<JournalArticle> list = findByG_T(groupId, templateId, 0, 1,
11250                                    orderByComparator);
11251    
11252                    if (!list.isEmpty()) {
11253                            return list.get(0);
11254                    }
11255    
11256                    return null;
11257            }
11258    
11259            /**
11260             * Returns the last journal article in the ordered set where groupId = &#63; and templateId = &#63;.
11261             *
11262             * @param groupId the group ID
11263             * @param templateId the template ID
11264             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11265             * @return the last matching journal article
11266             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11267             * @throws SystemException if a system exception occurred
11268             */
11269            public JournalArticle findByG_T_Last(long groupId, String templateId,
11270                    OrderByComparator orderByComparator)
11271                    throws NoSuchArticleException, SystemException {
11272                    JournalArticle journalArticle = fetchByG_T_Last(groupId, templateId,
11273                                    orderByComparator);
11274    
11275                    if (journalArticle != null) {
11276                            return journalArticle;
11277                    }
11278    
11279                    StringBundler msg = new StringBundler(6);
11280    
11281                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11282    
11283                    msg.append("groupId=");
11284                    msg.append(groupId);
11285    
11286                    msg.append(", templateId=");
11287                    msg.append(templateId);
11288    
11289                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11290    
11291                    throw new NoSuchArticleException(msg.toString());
11292            }
11293    
11294            /**
11295             * Returns the last journal article in the ordered set where groupId = &#63; and templateId = &#63;.
11296             *
11297             * @param groupId the group ID
11298             * @param templateId the template ID
11299             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11300             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
11301             * @throws SystemException if a system exception occurred
11302             */
11303            public JournalArticle fetchByG_T_Last(long groupId, String templateId,
11304                    OrderByComparator orderByComparator) throws SystemException {
11305                    int count = countByG_T(groupId, templateId);
11306    
11307                    List<JournalArticle> list = findByG_T(groupId, templateId, count - 1,
11308                                    count, orderByComparator);
11309    
11310                    if (!list.isEmpty()) {
11311                            return list.get(0);
11312                    }
11313    
11314                    return null;
11315            }
11316    
11317            /**
11318             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and templateId = &#63;.
11319             *
11320             * @param id the primary key of the current journal article
11321             * @param groupId the group ID
11322             * @param templateId the template ID
11323             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11324             * @return the previous, current, and next journal article
11325             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
11326             * @throws SystemException if a system exception occurred
11327             */
11328            public JournalArticle[] findByG_T_PrevAndNext(long id, long groupId,
11329                    String templateId, OrderByComparator orderByComparator)
11330                    throws NoSuchArticleException, SystemException {
11331                    JournalArticle journalArticle = findByPrimaryKey(id);
11332    
11333                    Session session = null;
11334    
11335                    try {
11336                            session = openSession();
11337    
11338                            JournalArticle[] array = new JournalArticleImpl[3];
11339    
11340                            array[0] = getByG_T_PrevAndNext(session, journalArticle, groupId,
11341                                            templateId, orderByComparator, true);
11342    
11343                            array[1] = journalArticle;
11344    
11345                            array[2] = getByG_T_PrevAndNext(session, journalArticle, groupId,
11346                                            templateId, orderByComparator, false);
11347    
11348                            return array;
11349                    }
11350                    catch (Exception e) {
11351                            throw processException(e);
11352                    }
11353                    finally {
11354                            closeSession(session);
11355                    }
11356            }
11357    
11358            protected JournalArticle getByG_T_PrevAndNext(Session session,
11359                    JournalArticle journalArticle, long groupId, String templateId,
11360                    OrderByComparator orderByComparator, boolean previous) {
11361                    StringBundler query = null;
11362    
11363                    if (orderByComparator != null) {
11364                            query = new StringBundler(6 +
11365                                            (orderByComparator.getOrderByFields().length * 6));
11366                    }
11367                    else {
11368                            query = new StringBundler(3);
11369                    }
11370    
11371                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11372    
11373                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
11374    
11375                    if (templateId == null) {
11376                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
11377                    }
11378                    else {
11379                            if (templateId.equals(StringPool.BLANK)) {
11380                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
11381                            }
11382                            else {
11383                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
11384                            }
11385                    }
11386    
11387                    if (orderByComparator != null) {
11388                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11389    
11390                            if (orderByConditionFields.length > 0) {
11391                                    query.append(WHERE_AND);
11392                            }
11393    
11394                            for (int i = 0; i < orderByConditionFields.length; i++) {
11395                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11396                                    query.append(orderByConditionFields[i]);
11397    
11398                                    if ((i + 1) < orderByConditionFields.length) {
11399                                            if (orderByComparator.isAscending() ^ previous) {
11400                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11401                                            }
11402                                            else {
11403                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11404                                            }
11405                                    }
11406                                    else {
11407                                            if (orderByComparator.isAscending() ^ previous) {
11408                                                    query.append(WHERE_GREATER_THAN);
11409                                            }
11410                                            else {
11411                                                    query.append(WHERE_LESSER_THAN);
11412                                            }
11413                                    }
11414                            }
11415    
11416                            query.append(ORDER_BY_CLAUSE);
11417    
11418                            String[] orderByFields = orderByComparator.getOrderByFields();
11419    
11420                            for (int i = 0; i < orderByFields.length; i++) {
11421                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11422                                    query.append(orderByFields[i]);
11423    
11424                                    if ((i + 1) < orderByFields.length) {
11425                                            if (orderByComparator.isAscending() ^ previous) {
11426                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11427                                            }
11428                                            else {
11429                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11430                                            }
11431                                    }
11432                                    else {
11433                                            if (orderByComparator.isAscending() ^ previous) {
11434                                                    query.append(ORDER_BY_ASC);
11435                                            }
11436                                            else {
11437                                                    query.append(ORDER_BY_DESC);
11438                                            }
11439                                    }
11440                            }
11441                    }
11442                    else {
11443                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11444                    }
11445    
11446                    String sql = query.toString();
11447    
11448                    Query q = session.createQuery(sql);
11449    
11450                    q.setFirstResult(0);
11451                    q.setMaxResults(2);
11452    
11453                    QueryPos qPos = QueryPos.getInstance(q);
11454    
11455                    qPos.add(groupId);
11456    
11457                    if (templateId != null) {
11458                            qPos.add(templateId);
11459                    }
11460    
11461                    if (orderByComparator != null) {
11462                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
11463    
11464                            for (Object value : values) {
11465                                    qPos.add(value);
11466                            }
11467                    }
11468    
11469                    List<JournalArticle> list = q.list();
11470    
11471                    if (list.size() == 2) {
11472                            return list.get(1);
11473                    }
11474                    else {
11475                            return null;
11476                    }
11477            }
11478    
11479            /**
11480             * Returns all the journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
11481             *
11482             * @param groupId the group ID
11483             * @param templateId the template ID
11484             * @return the matching journal articles that the user has permission to view
11485             * @throws SystemException if a system exception occurred
11486             */
11487            public List<JournalArticle> filterFindByG_T(long groupId, String templateId)
11488                    throws SystemException {
11489                    return filterFindByG_T(groupId, templateId, QueryUtil.ALL_POS,
11490                            QueryUtil.ALL_POS, null);
11491            }
11492    
11493            /**
11494             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
11495             *
11496             * <p>
11497             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11498             * </p>
11499             *
11500             * @param groupId the group ID
11501             * @param templateId the template ID
11502             * @param start the lower bound of the range of journal articles
11503             * @param end the upper bound of the range of journal articles (not inclusive)
11504             * @return the range of matching journal articles that the user has permission to view
11505             * @throws SystemException if a system exception occurred
11506             */
11507            public List<JournalArticle> filterFindByG_T(long groupId,
11508                    String templateId, int start, int end) throws SystemException {
11509                    return filterFindByG_T(groupId, templateId, start, end, null);
11510            }
11511    
11512            /**
11513             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and templateId = &#63;.
11514             *
11515             * <p>
11516             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11517             * </p>
11518             *
11519             * @param groupId the group ID
11520             * @param templateId the template ID
11521             * @param start the lower bound of the range of journal articles
11522             * @param end the upper bound of the range of journal articles (not inclusive)
11523             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11524             * @return the ordered range of matching journal articles that the user has permission to view
11525             * @throws SystemException if a system exception occurred
11526             */
11527            public List<JournalArticle> filterFindByG_T(long groupId,
11528                    String templateId, int start, int end,
11529                    OrderByComparator orderByComparator) throws SystemException {
11530                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11531                            return findByG_T(groupId, templateId, start, end, orderByComparator);
11532                    }
11533    
11534                    StringBundler query = null;
11535    
11536                    if (orderByComparator != null) {
11537                            query = new StringBundler(4 +
11538                                            (orderByComparator.getOrderByFields().length * 3));
11539                    }
11540                    else {
11541                            query = new StringBundler(4);
11542                    }
11543    
11544                    if (getDB().isSupportsInlineDistinct()) {
11545                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
11546                    }
11547                    else {
11548                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
11549                    }
11550    
11551                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
11552    
11553                    if (templateId == null) {
11554                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
11555                    }
11556                    else {
11557                            if (templateId.equals(StringPool.BLANK)) {
11558                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
11559                            }
11560                            else {
11561                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
11562                            }
11563                    }
11564    
11565                    if (!getDB().isSupportsInlineDistinct()) {
11566                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
11567                    }
11568    
11569                    if (orderByComparator != null) {
11570                            if (getDB().isSupportsInlineDistinct()) {
11571                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11572                                            orderByComparator);
11573                            }
11574                            else {
11575                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11576                                            orderByComparator);
11577                            }
11578                    }
11579                    else {
11580                            if (getDB().isSupportsInlineDistinct()) {
11581                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11582                            }
11583                            else {
11584                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
11585                            }
11586                    }
11587    
11588                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11589                                    JournalArticle.class.getName(),
11590                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11591    
11592                    Session session = null;
11593    
11594                    try {
11595                            session = openSession();
11596    
11597                            SQLQuery q = session.createSQLQuery(sql);
11598    
11599                            if (getDB().isSupportsInlineDistinct()) {
11600                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
11601                            }
11602                            else {
11603                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
11604                            }
11605    
11606                            QueryPos qPos = QueryPos.getInstance(q);
11607    
11608                            qPos.add(groupId);
11609    
11610                            if (templateId != null) {
11611                                    qPos.add(templateId);
11612                            }
11613    
11614                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
11615                                    end);
11616                    }
11617                    catch (Exception e) {
11618                            throw processException(e);
11619                    }
11620                    finally {
11621                            closeSession(session);
11622                    }
11623            }
11624    
11625            /**
11626             * 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;.
11627             *
11628             * @param id the primary key of the current journal article
11629             * @param groupId the group ID
11630             * @param templateId the template ID
11631             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11632             * @return the previous, current, and next journal article
11633             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
11634             * @throws SystemException if a system exception occurred
11635             */
11636            public JournalArticle[] filterFindByG_T_PrevAndNext(long id, long groupId,
11637                    String templateId, OrderByComparator orderByComparator)
11638                    throws NoSuchArticleException, SystemException {
11639                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11640                            return findByG_T_PrevAndNext(id, groupId, templateId,
11641                                    orderByComparator);
11642                    }
11643    
11644                    JournalArticle journalArticle = findByPrimaryKey(id);
11645    
11646                    Session session = null;
11647    
11648                    try {
11649                            session = openSession();
11650    
11651                            JournalArticle[] array = new JournalArticleImpl[3];
11652    
11653                            array[0] = filterGetByG_T_PrevAndNext(session, journalArticle,
11654                                            groupId, templateId, orderByComparator, true);
11655    
11656                            array[1] = journalArticle;
11657    
11658                            array[2] = filterGetByG_T_PrevAndNext(session, journalArticle,
11659                                            groupId, templateId, orderByComparator, false);
11660    
11661                            return array;
11662                    }
11663                    catch (Exception e) {
11664                            throw processException(e);
11665                    }
11666                    finally {
11667                            closeSession(session);
11668                    }
11669            }
11670    
11671            protected JournalArticle filterGetByG_T_PrevAndNext(Session session,
11672                    JournalArticle journalArticle, long groupId, String templateId,
11673                    OrderByComparator orderByComparator, boolean previous) {
11674                    StringBundler query = null;
11675    
11676                    if (orderByComparator != null) {
11677                            query = new StringBundler(6 +
11678                                            (orderByComparator.getOrderByFields().length * 6));
11679                    }
11680                    else {
11681                            query = new StringBundler(3);
11682                    }
11683    
11684                    if (getDB().isSupportsInlineDistinct()) {
11685                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
11686                    }
11687                    else {
11688                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
11689                    }
11690    
11691                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
11692    
11693                    if (templateId == null) {
11694                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
11695                    }
11696                    else {
11697                            if (templateId.equals(StringPool.BLANK)) {
11698                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
11699                            }
11700                            else {
11701                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
11702                            }
11703                    }
11704    
11705                    if (!getDB().isSupportsInlineDistinct()) {
11706                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
11707                    }
11708    
11709                    if (orderByComparator != null) {
11710                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11711    
11712                            if (orderByConditionFields.length > 0) {
11713                                    query.append(WHERE_AND);
11714                            }
11715    
11716                            for (int i = 0; i < orderByConditionFields.length; i++) {
11717                                    if (getDB().isSupportsInlineDistinct()) {
11718                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11719                                    }
11720                                    else {
11721                                            query.append(_ORDER_BY_ENTITY_TABLE);
11722                                    }
11723    
11724                                    query.append(orderByConditionFields[i]);
11725    
11726                                    if ((i + 1) < orderByConditionFields.length) {
11727                                            if (orderByComparator.isAscending() ^ previous) {
11728                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11729                                            }
11730                                            else {
11731                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11732                                            }
11733                                    }
11734                                    else {
11735                                            if (orderByComparator.isAscending() ^ previous) {
11736                                                    query.append(WHERE_GREATER_THAN);
11737                                            }
11738                                            else {
11739                                                    query.append(WHERE_LESSER_THAN);
11740                                            }
11741                                    }
11742                            }
11743    
11744                            query.append(ORDER_BY_CLAUSE);
11745    
11746                            String[] orderByFields = orderByComparator.getOrderByFields();
11747    
11748                            for (int i = 0; i < orderByFields.length; i++) {
11749                                    if (getDB().isSupportsInlineDistinct()) {
11750                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11751                                    }
11752                                    else {
11753                                            query.append(_ORDER_BY_ENTITY_TABLE);
11754                                    }
11755    
11756                                    query.append(orderByFields[i]);
11757    
11758                                    if ((i + 1) < orderByFields.length) {
11759                                            if (orderByComparator.isAscending() ^ previous) {
11760                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11761                                            }
11762                                            else {
11763                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11764                                            }
11765                                    }
11766                                    else {
11767                                            if (orderByComparator.isAscending() ^ previous) {
11768                                                    query.append(ORDER_BY_ASC);
11769                                            }
11770                                            else {
11771                                                    query.append(ORDER_BY_DESC);
11772                                            }
11773                                    }
11774                            }
11775                    }
11776                    else {
11777                            if (getDB().isSupportsInlineDistinct()) {
11778                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11779                            }
11780                            else {
11781                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
11782                            }
11783                    }
11784    
11785                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11786                                    JournalArticle.class.getName(),
11787                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11788    
11789                    SQLQuery q = session.createSQLQuery(sql);
11790    
11791                    q.setFirstResult(0);
11792                    q.setMaxResults(2);
11793    
11794                    if (getDB().isSupportsInlineDistinct()) {
11795                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
11796                    }
11797                    else {
11798                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
11799                    }
11800    
11801                    QueryPos qPos = QueryPos.getInstance(q);
11802    
11803                    qPos.add(groupId);
11804    
11805                    if (templateId != null) {
11806                            qPos.add(templateId);
11807                    }
11808    
11809                    if (orderByComparator != null) {
11810                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
11811    
11812                            for (Object value : values) {
11813                                    qPos.add(value);
11814                            }
11815                    }
11816    
11817                    List<JournalArticle> list = q.list();
11818    
11819                    if (list.size() == 2) {
11820                            return list.get(1);
11821                    }
11822                    else {
11823                            return null;
11824                    }
11825            }
11826    
11827            /**
11828             * Removes all the journal articles where groupId = &#63; and templateId = &#63; from the database.
11829             *
11830             * @param groupId the group ID
11831             * @param templateId the template ID
11832             * @throws SystemException if a system exception occurred
11833             */
11834            public void removeByG_T(long groupId, String templateId)
11835                    throws SystemException {
11836                    for (JournalArticle journalArticle : findByG_T(groupId, templateId,
11837                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
11838                            remove(journalArticle);
11839                    }
11840            }
11841    
11842            /**
11843             * Returns the number of journal articles where groupId = &#63; and templateId = &#63;.
11844             *
11845             * @param groupId the group ID
11846             * @param templateId the template ID
11847             * @return the number of matching journal articles
11848             * @throws SystemException if a system exception occurred
11849             */
11850            public int countByG_T(long groupId, String templateId)
11851                    throws SystemException {
11852                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_T;
11853    
11854                    Object[] finderArgs = new Object[] { groupId, templateId };
11855    
11856                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
11857                                    this);
11858    
11859                    if (count == null) {
11860                            StringBundler query = new StringBundler(3);
11861    
11862                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
11863    
11864                            query.append(_FINDER_COLUMN_G_T_GROUPID_2);
11865    
11866                            if (templateId == null) {
11867                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
11868                            }
11869                            else {
11870                                    if (templateId.equals(StringPool.BLANK)) {
11871                                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
11872                                    }
11873                                    else {
11874                                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
11875                                    }
11876                            }
11877    
11878                            String sql = query.toString();
11879    
11880                            Session session = null;
11881    
11882                            try {
11883                                    session = openSession();
11884    
11885                                    Query q = session.createQuery(sql);
11886    
11887                                    QueryPos qPos = QueryPos.getInstance(q);
11888    
11889                                    qPos.add(groupId);
11890    
11891                                    if (templateId != null) {
11892                                            qPos.add(templateId);
11893                                    }
11894    
11895                                    count = (Long)q.uniqueResult();
11896    
11897                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
11898                            }
11899                            catch (Exception e) {
11900                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11901    
11902                                    throw processException(e);
11903                            }
11904                            finally {
11905                                    closeSession(session);
11906                            }
11907                    }
11908    
11909                    return count.intValue();
11910            }
11911    
11912            /**
11913             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
11914             *
11915             * @param groupId the group ID
11916             * @param templateId the template ID
11917             * @return the number of matching journal articles that the user has permission to view
11918             * @throws SystemException if a system exception occurred
11919             */
11920            public int filterCountByG_T(long groupId, String templateId)
11921                    throws SystemException {
11922                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11923                            return countByG_T(groupId, templateId);
11924                    }
11925    
11926                    StringBundler query = new StringBundler(3);
11927    
11928                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
11929    
11930                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
11931    
11932                    if (templateId == null) {
11933                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
11934                    }
11935                    else {
11936                            if (templateId.equals(StringPool.BLANK)) {
11937                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
11938                            }
11939                            else {
11940                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
11941                            }
11942                    }
11943    
11944                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11945                                    JournalArticle.class.getName(),
11946                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11947    
11948                    Session session = null;
11949    
11950                    try {
11951                            session = openSession();
11952    
11953                            SQLQuery q = session.createSQLQuery(sql);
11954    
11955                            q.addScalar(COUNT_COLUMN_NAME,
11956                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11957    
11958                            QueryPos qPos = QueryPos.getInstance(q);
11959    
11960                            qPos.add(groupId);
11961    
11962                            if (templateId != null) {
11963                                    qPos.add(templateId);
11964                            }
11965    
11966                            Long count = (Long)q.uniqueResult();
11967    
11968                            return count.intValue();
11969                    }
11970                    catch (Exception e) {
11971                            throw processException(e);
11972                    }
11973                    finally {
11974                            closeSession(session);
11975                    }
11976            }
11977    
11978            private static final String _FINDER_COLUMN_G_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
11979            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
11980            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
11981            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = ?)";
11982            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
11983                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
11984                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
11985                            "findByG_L",
11986                            new String[] {
11987                                    Long.class.getName(), String.class.getName(),
11988                                    
11989                            Integer.class.getName(), Integer.class.getName(),
11990                                    OrderByComparator.class.getName()
11991                            });
11992            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
11993                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
11994                            JournalArticleImpl.class,
11995                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_L",
11996                            new String[] { Long.class.getName(), String.class.getName() },
11997                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
11998                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK |
11999                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
12000                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
12001            public static final FinderPath FINDER_PATH_COUNT_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
12002                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
12003                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_L",
12004                            new String[] { Long.class.getName(), String.class.getName() });
12005    
12006            /**
12007             * Returns all the journal articles where groupId = &#63; and layoutUuid = &#63;.
12008             *
12009             * @param groupId the group ID
12010             * @param layoutUuid the layout uuid
12011             * @return the matching journal articles
12012             * @throws SystemException if a system exception occurred
12013             */
12014            public List<JournalArticle> findByG_L(long groupId, String layoutUuid)
12015                    throws SystemException {
12016                    return findByG_L(groupId, layoutUuid, QueryUtil.ALL_POS,
12017                            QueryUtil.ALL_POS, null);
12018            }
12019    
12020            /**
12021             * Returns a range of all the journal articles where groupId = &#63; and layoutUuid = &#63;.
12022             *
12023             * <p>
12024             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12025             * </p>
12026             *
12027             * @param groupId the group ID
12028             * @param layoutUuid the layout uuid
12029             * @param start the lower bound of the range of journal articles
12030             * @param end the upper bound of the range of journal articles (not inclusive)
12031             * @return the range of matching journal articles
12032             * @throws SystemException if a system exception occurred
12033             */
12034            public List<JournalArticle> findByG_L(long groupId, String layoutUuid,
12035                    int start, int end) throws SystemException {
12036                    return findByG_L(groupId, layoutUuid, start, end, null);
12037            }
12038    
12039            /**
12040             * Returns an ordered range of all the journal articles where groupId = &#63; and layoutUuid = &#63;.
12041             *
12042             * <p>
12043             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12044             * </p>
12045             *
12046             * @param groupId the group ID
12047             * @param layoutUuid the layout uuid
12048             * @param start the lower bound of the range of journal articles
12049             * @param end the upper bound of the range of journal articles (not inclusive)
12050             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12051             * @return the ordered range of matching journal articles
12052             * @throws SystemException if a system exception occurred
12053             */
12054            public List<JournalArticle> findByG_L(long groupId, String layoutUuid,
12055                    int start, int end, OrderByComparator orderByComparator)
12056                    throws SystemException {
12057                    boolean pagination = true;
12058                    FinderPath finderPath = null;
12059                    Object[] finderArgs = null;
12060    
12061                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12062                                    (orderByComparator == null)) {
12063                            pagination = false;
12064                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L;
12065                            finderArgs = new Object[] { groupId, layoutUuid };
12066                    }
12067                    else {
12068                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_L;
12069                            finderArgs = new Object[] {
12070                                            groupId, layoutUuid,
12071                                            
12072                                            start, end, orderByComparator
12073                                    };
12074                    }
12075    
12076                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
12077                                    finderArgs, this);
12078    
12079                    if ((list != null) && !list.isEmpty()) {
12080                            for (JournalArticle journalArticle : list) {
12081                                    if ((groupId != journalArticle.getGroupId()) ||
12082                                                    !Validator.equals(layoutUuid,
12083                                                            journalArticle.getLayoutUuid())) {
12084                                            list = null;
12085    
12086                                            break;
12087                                    }
12088                            }
12089                    }
12090    
12091                    if (list == null) {
12092                            StringBundler query = null;
12093    
12094                            if (orderByComparator != null) {
12095                                    query = new StringBundler(4 +
12096                                                    (orderByComparator.getOrderByFields().length * 3));
12097                            }
12098                            else {
12099                                    query = new StringBundler(4);
12100                            }
12101    
12102                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12103    
12104                            query.append(_FINDER_COLUMN_G_L_GROUPID_2);
12105    
12106                            if (layoutUuid == null) {
12107                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
12108                            }
12109                            else {
12110                                    if (layoutUuid.equals(StringPool.BLANK)) {
12111                                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
12112                                    }
12113                                    else {
12114                                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
12115                                    }
12116                            }
12117    
12118                            if (orderByComparator != null) {
12119                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12120                                            orderByComparator);
12121                            }
12122                            else
12123                             if (pagination) {
12124                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12125                            }
12126    
12127                            String sql = query.toString();
12128    
12129                            Session session = null;
12130    
12131                            try {
12132                                    session = openSession();
12133    
12134                                    Query q = session.createQuery(sql);
12135    
12136                                    QueryPos qPos = QueryPos.getInstance(q);
12137    
12138                                    qPos.add(groupId);
12139    
12140                                    if (layoutUuid != null) {
12141                                            qPos.add(layoutUuid);
12142                                    }
12143    
12144                                    if (!pagination) {
12145                                            list = (List<JournalArticle>)QueryUtil.list(q,
12146                                                            getDialect(), start, end, false);
12147    
12148                                            Collections.sort(list);
12149    
12150                                            list = new UnmodifiableList<JournalArticle>(list);
12151                                    }
12152                                    else {
12153                                            list = (List<JournalArticle>)QueryUtil.list(q,
12154                                                            getDialect(), start, end);
12155                                    }
12156    
12157                                    cacheResult(list);
12158    
12159                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
12160                            }
12161                            catch (Exception e) {
12162                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12163    
12164                                    throw processException(e);
12165                            }
12166                            finally {
12167                                    closeSession(session);
12168                            }
12169                    }
12170    
12171                    return list;
12172            }
12173    
12174            /**
12175             * Returns the first journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
12176             *
12177             * @param groupId the group ID
12178             * @param layoutUuid the layout uuid
12179             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12180             * @return the first matching journal article
12181             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12182             * @throws SystemException if a system exception occurred
12183             */
12184            public JournalArticle findByG_L_First(long groupId, String layoutUuid,
12185                    OrderByComparator orderByComparator)
12186                    throws NoSuchArticleException, SystemException {
12187                    JournalArticle journalArticle = fetchByG_L_First(groupId, layoutUuid,
12188                                    orderByComparator);
12189    
12190                    if (journalArticle != null) {
12191                            return journalArticle;
12192                    }
12193    
12194                    StringBundler msg = new StringBundler(6);
12195    
12196                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12197    
12198                    msg.append("groupId=");
12199                    msg.append(groupId);
12200    
12201                    msg.append(", layoutUuid=");
12202                    msg.append(layoutUuid);
12203    
12204                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12205    
12206                    throw new NoSuchArticleException(msg.toString());
12207            }
12208    
12209            /**
12210             * Returns the first journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
12211             *
12212             * @param groupId the group ID
12213             * @param layoutUuid the layout uuid
12214             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12215             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
12216             * @throws SystemException if a system exception occurred
12217             */
12218            public JournalArticle fetchByG_L_First(long groupId, String layoutUuid,
12219                    OrderByComparator orderByComparator) throws SystemException {
12220                    List<JournalArticle> list = findByG_L(groupId, layoutUuid, 0, 1,
12221                                    orderByComparator);
12222    
12223                    if (!list.isEmpty()) {
12224                            return list.get(0);
12225                    }
12226    
12227                    return null;
12228            }
12229    
12230            /**
12231             * Returns the last journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
12232             *
12233             * @param groupId the group ID
12234             * @param layoutUuid the layout uuid
12235             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12236             * @return the last matching journal article
12237             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12238             * @throws SystemException if a system exception occurred
12239             */
12240            public JournalArticle findByG_L_Last(long groupId, String layoutUuid,
12241                    OrderByComparator orderByComparator)
12242                    throws NoSuchArticleException, SystemException {
12243                    JournalArticle journalArticle = fetchByG_L_Last(groupId, layoutUuid,
12244                                    orderByComparator);
12245    
12246                    if (journalArticle != null) {
12247                            return journalArticle;
12248                    }
12249    
12250                    StringBundler msg = new StringBundler(6);
12251    
12252                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12253    
12254                    msg.append("groupId=");
12255                    msg.append(groupId);
12256    
12257                    msg.append(", layoutUuid=");
12258                    msg.append(layoutUuid);
12259    
12260                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12261    
12262                    throw new NoSuchArticleException(msg.toString());
12263            }
12264    
12265            /**
12266             * Returns the last journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
12267             *
12268             * @param groupId the group ID
12269             * @param layoutUuid the layout uuid
12270             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12271             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
12272             * @throws SystemException if a system exception occurred
12273             */
12274            public JournalArticle fetchByG_L_Last(long groupId, String layoutUuid,
12275                    OrderByComparator orderByComparator) throws SystemException {
12276                    int count = countByG_L(groupId, layoutUuid);
12277    
12278                    List<JournalArticle> list = findByG_L(groupId, layoutUuid, count - 1,
12279                                    count, orderByComparator);
12280    
12281                    if (!list.isEmpty()) {
12282                            return list.get(0);
12283                    }
12284    
12285                    return null;
12286            }
12287    
12288            /**
12289             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
12290             *
12291             * @param id the primary key of the current journal article
12292             * @param groupId the group ID
12293             * @param layoutUuid the layout uuid
12294             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12295             * @return the previous, current, and next journal article
12296             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
12297             * @throws SystemException if a system exception occurred
12298             */
12299            public JournalArticle[] findByG_L_PrevAndNext(long id, long groupId,
12300                    String layoutUuid, OrderByComparator orderByComparator)
12301                    throws NoSuchArticleException, SystemException {
12302                    JournalArticle journalArticle = findByPrimaryKey(id);
12303    
12304                    Session session = null;
12305    
12306                    try {
12307                            session = openSession();
12308    
12309                            JournalArticle[] array = new JournalArticleImpl[3];
12310    
12311                            array[0] = getByG_L_PrevAndNext(session, journalArticle, groupId,
12312                                            layoutUuid, orderByComparator, true);
12313    
12314                            array[1] = journalArticle;
12315    
12316                            array[2] = getByG_L_PrevAndNext(session, journalArticle, groupId,
12317                                            layoutUuid, orderByComparator, false);
12318    
12319                            return array;
12320                    }
12321                    catch (Exception e) {
12322                            throw processException(e);
12323                    }
12324                    finally {
12325                            closeSession(session);
12326                    }
12327            }
12328    
12329            protected JournalArticle getByG_L_PrevAndNext(Session session,
12330                    JournalArticle journalArticle, long groupId, String layoutUuid,
12331                    OrderByComparator orderByComparator, boolean previous) {
12332                    StringBundler query = null;
12333    
12334                    if (orderByComparator != null) {
12335                            query = new StringBundler(6 +
12336                                            (orderByComparator.getOrderByFields().length * 6));
12337                    }
12338                    else {
12339                            query = new StringBundler(3);
12340                    }
12341    
12342                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12343    
12344                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
12345    
12346                    if (layoutUuid == null) {
12347                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
12348                    }
12349                    else {
12350                            if (layoutUuid.equals(StringPool.BLANK)) {
12351                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
12352                            }
12353                            else {
12354                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
12355                            }
12356                    }
12357    
12358                    if (orderByComparator != null) {
12359                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12360    
12361                            if (orderByConditionFields.length > 0) {
12362                                    query.append(WHERE_AND);
12363                            }
12364    
12365                            for (int i = 0; i < orderByConditionFields.length; i++) {
12366                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12367                                    query.append(orderByConditionFields[i]);
12368    
12369                                    if ((i + 1) < orderByConditionFields.length) {
12370                                            if (orderByComparator.isAscending() ^ previous) {
12371                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12372                                            }
12373                                            else {
12374                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12375                                            }
12376                                    }
12377                                    else {
12378                                            if (orderByComparator.isAscending() ^ previous) {
12379                                                    query.append(WHERE_GREATER_THAN);
12380                                            }
12381                                            else {
12382                                                    query.append(WHERE_LESSER_THAN);
12383                                            }
12384                                    }
12385                            }
12386    
12387                            query.append(ORDER_BY_CLAUSE);
12388    
12389                            String[] orderByFields = orderByComparator.getOrderByFields();
12390    
12391                            for (int i = 0; i < orderByFields.length; i++) {
12392                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12393                                    query.append(orderByFields[i]);
12394    
12395                                    if ((i + 1) < orderByFields.length) {
12396                                            if (orderByComparator.isAscending() ^ previous) {
12397                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12398                                            }
12399                                            else {
12400                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12401                                            }
12402                                    }
12403                                    else {
12404                                            if (orderByComparator.isAscending() ^ previous) {
12405                                                    query.append(ORDER_BY_ASC);
12406                                            }
12407                                            else {
12408                                                    query.append(ORDER_BY_DESC);
12409                                            }
12410                                    }
12411                            }
12412                    }
12413                    else {
12414                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12415                    }
12416    
12417                    String sql = query.toString();
12418    
12419                    Query q = session.createQuery(sql);
12420    
12421                    q.setFirstResult(0);
12422                    q.setMaxResults(2);
12423    
12424                    QueryPos qPos = QueryPos.getInstance(q);
12425    
12426                    qPos.add(groupId);
12427    
12428                    if (layoutUuid != null) {
12429                            qPos.add(layoutUuid);
12430                    }
12431    
12432                    if (orderByComparator != null) {
12433                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12434    
12435                            for (Object value : values) {
12436                                    qPos.add(value);
12437                            }
12438                    }
12439    
12440                    List<JournalArticle> list = q.list();
12441    
12442                    if (list.size() == 2) {
12443                            return list.get(1);
12444                    }
12445                    else {
12446                            return null;
12447                    }
12448            }
12449    
12450            /**
12451             * Returns all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
12452             *
12453             * @param groupId the group ID
12454             * @param layoutUuid the layout uuid
12455             * @return the matching journal articles that the user has permission to view
12456             * @throws SystemException if a system exception occurred
12457             */
12458            public List<JournalArticle> filterFindByG_L(long groupId, String layoutUuid)
12459                    throws SystemException {
12460                    return filterFindByG_L(groupId, layoutUuid, QueryUtil.ALL_POS,
12461                            QueryUtil.ALL_POS, null);
12462            }
12463    
12464            /**
12465             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
12466             *
12467             * <p>
12468             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12469             * </p>
12470             *
12471             * @param groupId the group ID
12472             * @param layoutUuid the layout uuid
12473             * @param start the lower bound of the range of journal articles
12474             * @param end the upper bound of the range of journal articles (not inclusive)
12475             * @return the range of matching journal articles that the user has permission to view
12476             * @throws SystemException if a system exception occurred
12477             */
12478            public List<JournalArticle> filterFindByG_L(long groupId,
12479                    String layoutUuid, int start, int end) throws SystemException {
12480                    return filterFindByG_L(groupId, layoutUuid, start, end, null);
12481            }
12482    
12483            /**
12484             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and layoutUuid = &#63;.
12485             *
12486             * <p>
12487             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12488             * </p>
12489             *
12490             * @param groupId the group ID
12491             * @param layoutUuid the layout uuid
12492             * @param start the lower bound of the range of journal articles
12493             * @param end the upper bound of the range of journal articles (not inclusive)
12494             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12495             * @return the ordered range of matching journal articles that the user has permission to view
12496             * @throws SystemException if a system exception occurred
12497             */
12498            public List<JournalArticle> filterFindByG_L(long groupId,
12499                    String layoutUuid, int start, int end,
12500                    OrderByComparator orderByComparator) throws SystemException {
12501                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12502                            return findByG_L(groupId, layoutUuid, start, end, orderByComparator);
12503                    }
12504    
12505                    StringBundler query = null;
12506    
12507                    if (orderByComparator != null) {
12508                            query = new StringBundler(4 +
12509                                            (orderByComparator.getOrderByFields().length * 3));
12510                    }
12511                    else {
12512                            query = new StringBundler(4);
12513                    }
12514    
12515                    if (getDB().isSupportsInlineDistinct()) {
12516                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
12517                    }
12518                    else {
12519                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
12520                    }
12521    
12522                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
12523    
12524                    if (layoutUuid == null) {
12525                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
12526                    }
12527                    else {
12528                            if (layoutUuid.equals(StringPool.BLANK)) {
12529                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
12530                            }
12531                            else {
12532                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
12533                            }
12534                    }
12535    
12536                    if (!getDB().isSupportsInlineDistinct()) {
12537                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
12538                    }
12539    
12540                    if (orderByComparator != null) {
12541                            if (getDB().isSupportsInlineDistinct()) {
12542                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12543                                            orderByComparator);
12544                            }
12545                            else {
12546                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12547                                            orderByComparator);
12548                            }
12549                    }
12550                    else {
12551                            if (getDB().isSupportsInlineDistinct()) {
12552                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12553                            }
12554                            else {
12555                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12556                            }
12557                    }
12558    
12559                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12560                                    JournalArticle.class.getName(),
12561                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12562    
12563                    Session session = null;
12564    
12565                    try {
12566                            session = openSession();
12567    
12568                            SQLQuery q = session.createSQLQuery(sql);
12569    
12570                            if (getDB().isSupportsInlineDistinct()) {
12571                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12572                            }
12573                            else {
12574                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12575                            }
12576    
12577                            QueryPos qPos = QueryPos.getInstance(q);
12578    
12579                            qPos.add(groupId);
12580    
12581                            if (layoutUuid != null) {
12582                                    qPos.add(layoutUuid);
12583                            }
12584    
12585                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
12586                                    end);
12587                    }
12588                    catch (Exception e) {
12589                            throw processException(e);
12590                    }
12591                    finally {
12592                            closeSession(session);
12593                    }
12594            }
12595    
12596            /**
12597             * 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;.
12598             *
12599             * @param id the primary key of the current journal article
12600             * @param groupId the group ID
12601             * @param layoutUuid the layout uuid
12602             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12603             * @return the previous, current, and next journal article
12604             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
12605             * @throws SystemException if a system exception occurred
12606             */
12607            public JournalArticle[] filterFindByG_L_PrevAndNext(long id, long groupId,
12608                    String layoutUuid, OrderByComparator orderByComparator)
12609                    throws NoSuchArticleException, SystemException {
12610                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12611                            return findByG_L_PrevAndNext(id, groupId, layoutUuid,
12612                                    orderByComparator);
12613                    }
12614    
12615                    JournalArticle journalArticle = findByPrimaryKey(id);
12616    
12617                    Session session = null;
12618    
12619                    try {
12620                            session = openSession();
12621    
12622                            JournalArticle[] array = new JournalArticleImpl[3];
12623    
12624                            array[0] = filterGetByG_L_PrevAndNext(session, journalArticle,
12625                                            groupId, layoutUuid, orderByComparator, true);
12626    
12627                            array[1] = journalArticle;
12628    
12629                            array[2] = filterGetByG_L_PrevAndNext(session, journalArticle,
12630                                            groupId, layoutUuid, orderByComparator, false);
12631    
12632                            return array;
12633                    }
12634                    catch (Exception e) {
12635                            throw processException(e);
12636                    }
12637                    finally {
12638                            closeSession(session);
12639                    }
12640            }
12641    
12642            protected JournalArticle filterGetByG_L_PrevAndNext(Session session,
12643                    JournalArticle journalArticle, long groupId, String layoutUuid,
12644                    OrderByComparator orderByComparator, boolean previous) {
12645                    StringBundler query = null;
12646    
12647                    if (orderByComparator != null) {
12648                            query = new StringBundler(6 +
12649                                            (orderByComparator.getOrderByFields().length * 6));
12650                    }
12651                    else {
12652                            query = new StringBundler(3);
12653                    }
12654    
12655                    if (getDB().isSupportsInlineDistinct()) {
12656                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
12657                    }
12658                    else {
12659                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
12660                    }
12661    
12662                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
12663    
12664                    if (layoutUuid == null) {
12665                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
12666                    }
12667                    else {
12668                            if (layoutUuid.equals(StringPool.BLANK)) {
12669                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
12670                            }
12671                            else {
12672                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
12673                            }
12674                    }
12675    
12676                    if (!getDB().isSupportsInlineDistinct()) {
12677                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
12678                    }
12679    
12680                    if (orderByComparator != null) {
12681                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12682    
12683                            if (orderByConditionFields.length > 0) {
12684                                    query.append(WHERE_AND);
12685                            }
12686    
12687                            for (int i = 0; i < orderByConditionFields.length; i++) {
12688                                    if (getDB().isSupportsInlineDistinct()) {
12689                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12690                                    }
12691                                    else {
12692                                            query.append(_ORDER_BY_ENTITY_TABLE);
12693                                    }
12694    
12695                                    query.append(orderByConditionFields[i]);
12696    
12697                                    if ((i + 1) < orderByConditionFields.length) {
12698                                            if (orderByComparator.isAscending() ^ previous) {
12699                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12700                                            }
12701                                            else {
12702                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12703                                            }
12704                                    }
12705                                    else {
12706                                            if (orderByComparator.isAscending() ^ previous) {
12707                                                    query.append(WHERE_GREATER_THAN);
12708                                            }
12709                                            else {
12710                                                    query.append(WHERE_LESSER_THAN);
12711                                            }
12712                                    }
12713                            }
12714    
12715                            query.append(ORDER_BY_CLAUSE);
12716    
12717                            String[] orderByFields = orderByComparator.getOrderByFields();
12718    
12719                            for (int i = 0; i < orderByFields.length; i++) {
12720                                    if (getDB().isSupportsInlineDistinct()) {
12721                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12722                                    }
12723                                    else {
12724                                            query.append(_ORDER_BY_ENTITY_TABLE);
12725                                    }
12726    
12727                                    query.append(orderByFields[i]);
12728    
12729                                    if ((i + 1) < orderByFields.length) {
12730                                            if (orderByComparator.isAscending() ^ previous) {
12731                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12732                                            }
12733                                            else {
12734                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12735                                            }
12736                                    }
12737                                    else {
12738                                            if (orderByComparator.isAscending() ^ previous) {
12739                                                    query.append(ORDER_BY_ASC);
12740                                            }
12741                                            else {
12742                                                    query.append(ORDER_BY_DESC);
12743                                            }
12744                                    }
12745                            }
12746                    }
12747                    else {
12748                            if (getDB().isSupportsInlineDistinct()) {
12749                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12750                            }
12751                            else {
12752                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12753                            }
12754                    }
12755    
12756                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12757                                    JournalArticle.class.getName(),
12758                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12759    
12760                    SQLQuery q = session.createSQLQuery(sql);
12761    
12762                    q.setFirstResult(0);
12763                    q.setMaxResults(2);
12764    
12765                    if (getDB().isSupportsInlineDistinct()) {
12766                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12767                    }
12768                    else {
12769                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12770                    }
12771    
12772                    QueryPos qPos = QueryPos.getInstance(q);
12773    
12774                    qPos.add(groupId);
12775    
12776                    if (layoutUuid != null) {
12777                            qPos.add(layoutUuid);
12778                    }
12779    
12780                    if (orderByComparator != null) {
12781                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12782    
12783                            for (Object value : values) {
12784                                    qPos.add(value);
12785                            }
12786                    }
12787    
12788                    List<JournalArticle> list = q.list();
12789    
12790                    if (list.size() == 2) {
12791                            return list.get(1);
12792                    }
12793                    else {
12794                            return null;
12795                    }
12796            }
12797    
12798            /**
12799             * Removes all the journal articles where groupId = &#63; and layoutUuid = &#63; from the database.
12800             *
12801             * @param groupId the group ID
12802             * @param layoutUuid the layout uuid
12803             * @throws SystemException if a system exception occurred
12804             */
12805            public void removeByG_L(long groupId, String layoutUuid)
12806                    throws SystemException {
12807                    for (JournalArticle journalArticle : findByG_L(groupId, layoutUuid,
12808                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
12809                            remove(journalArticle);
12810                    }
12811            }
12812    
12813            /**
12814             * Returns the number of journal articles where groupId = &#63; and layoutUuid = &#63;.
12815             *
12816             * @param groupId the group ID
12817             * @param layoutUuid the layout uuid
12818             * @return the number of matching journal articles
12819             * @throws SystemException if a system exception occurred
12820             */
12821            public int countByG_L(long groupId, String layoutUuid)
12822                    throws SystemException {
12823                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_L;
12824    
12825                    Object[] finderArgs = new Object[] { groupId, layoutUuid };
12826    
12827                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
12828                                    this);
12829    
12830                    if (count == null) {
12831                            StringBundler query = new StringBundler(3);
12832    
12833                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
12834    
12835                            query.append(_FINDER_COLUMN_G_L_GROUPID_2);
12836    
12837                            if (layoutUuid == null) {
12838                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
12839                            }
12840                            else {
12841                                    if (layoutUuid.equals(StringPool.BLANK)) {
12842                                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
12843                                    }
12844                                    else {
12845                                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
12846                                    }
12847                            }
12848    
12849                            String sql = query.toString();
12850    
12851                            Session session = null;
12852    
12853                            try {
12854                                    session = openSession();
12855    
12856                                    Query q = session.createQuery(sql);
12857    
12858                                    QueryPos qPos = QueryPos.getInstance(q);
12859    
12860                                    qPos.add(groupId);
12861    
12862                                    if (layoutUuid != null) {
12863                                            qPos.add(layoutUuid);
12864                                    }
12865    
12866                                    count = (Long)q.uniqueResult();
12867    
12868                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
12869                            }
12870                            catch (Exception e) {
12871                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12872    
12873                                    throw processException(e);
12874                            }
12875                            finally {
12876                                    closeSession(session);
12877                            }
12878                    }
12879    
12880                    return count.intValue();
12881            }
12882    
12883            /**
12884             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
12885             *
12886             * @param groupId the group ID
12887             * @param layoutUuid the layout uuid
12888             * @return the number of matching journal articles that the user has permission to view
12889             * @throws SystemException if a system exception occurred
12890             */
12891            public int filterCountByG_L(long groupId, String layoutUuid)
12892                    throws SystemException {
12893                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12894                            return countByG_L(groupId, layoutUuid);
12895                    }
12896    
12897                    StringBundler query = new StringBundler(3);
12898    
12899                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
12900    
12901                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
12902    
12903                    if (layoutUuid == null) {
12904                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
12905                    }
12906                    else {
12907                            if (layoutUuid.equals(StringPool.BLANK)) {
12908                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
12909                            }
12910                            else {
12911                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
12912                            }
12913                    }
12914    
12915                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12916                                    JournalArticle.class.getName(),
12917                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12918    
12919                    Session session = null;
12920    
12921                    try {
12922                            session = openSession();
12923    
12924                            SQLQuery q = session.createSQLQuery(sql);
12925    
12926                            q.addScalar(COUNT_COLUMN_NAME,
12927                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
12928    
12929                            QueryPos qPos = QueryPos.getInstance(q);
12930    
12931                            qPos.add(groupId);
12932    
12933                            if (layoutUuid != null) {
12934                                    qPos.add(layoutUuid);
12935                            }
12936    
12937                            Long count = (Long)q.uniqueResult();
12938    
12939                            return count.intValue();
12940                    }
12941                    catch (Exception e) {
12942                            throw processException(e);
12943                    }
12944                    finally {
12945                            closeSession(session);
12946                    }
12947            }
12948    
12949            private static final String _FINDER_COLUMN_G_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
12950            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
12951            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
12952            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = ?)";
12953            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
12954                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
12955                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
12956                            "findByG_ST",
12957                            new String[] {
12958                                    Long.class.getName(), Integer.class.getName(),
12959                                    
12960                            Integer.class.getName(), Integer.class.getName(),
12961                                    OrderByComparator.class.getName()
12962                            });
12963            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
12964                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
12965                            JournalArticleImpl.class,
12966                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_ST",
12967                            new String[] { Long.class.getName(), Integer.class.getName() },
12968                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
12969                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
12970                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
12971                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
12972            public static final FinderPath FINDER_PATH_COUNT_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
12973                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
12974                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_ST",
12975                            new String[] { Long.class.getName(), Integer.class.getName() });
12976    
12977            /**
12978             * Returns all the journal articles where groupId = &#63; and status = &#63;.
12979             *
12980             * @param groupId the group ID
12981             * @param status the status
12982             * @return the matching journal articles
12983             * @throws SystemException if a system exception occurred
12984             */
12985            public List<JournalArticle> findByG_ST(long groupId, int status)
12986                    throws SystemException {
12987                    return findByG_ST(groupId, status, QueryUtil.ALL_POS,
12988                            QueryUtil.ALL_POS, null);
12989            }
12990    
12991            /**
12992             * Returns a range of all the journal articles where groupId = &#63; and status = &#63;.
12993             *
12994             * <p>
12995             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12996             * </p>
12997             *
12998             * @param groupId the group ID
12999             * @param status the status
13000             * @param start the lower bound of the range of journal articles
13001             * @param end the upper bound of the range of journal articles (not inclusive)
13002             * @return the range of matching journal articles
13003             * @throws SystemException if a system exception occurred
13004             */
13005            public List<JournalArticle> findByG_ST(long groupId, int status, int start,
13006                    int end) throws SystemException {
13007                    return findByG_ST(groupId, status, start, end, null);
13008            }
13009    
13010            /**
13011             * Returns an ordered range of all the journal articles where groupId = &#63; and status = &#63;.
13012             *
13013             * <p>
13014             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13015             * </p>
13016             *
13017             * @param groupId the group ID
13018             * @param status the status
13019             * @param start the lower bound of the range of journal articles
13020             * @param end the upper bound of the range of journal articles (not inclusive)
13021             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13022             * @return the ordered range of matching journal articles
13023             * @throws SystemException if a system exception occurred
13024             */
13025            public List<JournalArticle> findByG_ST(long groupId, int status, int start,
13026                    int end, OrderByComparator orderByComparator) throws SystemException {
13027                    boolean pagination = true;
13028                    FinderPath finderPath = null;
13029                    Object[] finderArgs = null;
13030    
13031                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13032                                    (orderByComparator == null)) {
13033                            pagination = false;
13034                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST;
13035                            finderArgs = new Object[] { groupId, status };
13036                    }
13037                    else {
13038                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_ST;
13039                            finderArgs = new Object[] {
13040                                            groupId, status,
13041                                            
13042                                            start, end, orderByComparator
13043                                    };
13044                    }
13045    
13046                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
13047                                    finderArgs, this);
13048    
13049                    if ((list != null) && !list.isEmpty()) {
13050                            for (JournalArticle journalArticle : list) {
13051                                    if ((groupId != journalArticle.getGroupId()) ||
13052                                                    (status != journalArticle.getStatus())) {
13053                                            list = null;
13054    
13055                                            break;
13056                                    }
13057                            }
13058                    }
13059    
13060                    if (list == null) {
13061                            StringBundler query = null;
13062    
13063                            if (orderByComparator != null) {
13064                                    query = new StringBundler(4 +
13065                                                    (orderByComparator.getOrderByFields().length * 3));
13066                            }
13067                            else {
13068                                    query = new StringBundler(4);
13069                            }
13070    
13071                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13072    
13073                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
13074    
13075                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
13076    
13077                            if (orderByComparator != null) {
13078                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13079                                            orderByComparator);
13080                            }
13081                            else
13082                             if (pagination) {
13083                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13084                            }
13085    
13086                            String sql = query.toString();
13087    
13088                            Session session = null;
13089    
13090                            try {
13091                                    session = openSession();
13092    
13093                                    Query q = session.createQuery(sql);
13094    
13095                                    QueryPos qPos = QueryPos.getInstance(q);
13096    
13097                                    qPos.add(groupId);
13098    
13099                                    qPos.add(status);
13100    
13101                                    if (!pagination) {
13102                                            list = (List<JournalArticle>)QueryUtil.list(q,
13103                                                            getDialect(), start, end, false);
13104    
13105                                            Collections.sort(list);
13106    
13107                                            list = new UnmodifiableList<JournalArticle>(list);
13108                                    }
13109                                    else {
13110                                            list = (List<JournalArticle>)QueryUtil.list(q,
13111                                                            getDialect(), start, end);
13112                                    }
13113    
13114                                    cacheResult(list);
13115    
13116                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
13117                            }
13118                            catch (Exception e) {
13119                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13120    
13121                                    throw processException(e);
13122                            }
13123                            finally {
13124                                    closeSession(session);
13125                            }
13126                    }
13127    
13128                    return list;
13129            }
13130    
13131            /**
13132             * Returns the first journal article in the ordered set where groupId = &#63; and status = &#63;.
13133             *
13134             * @param groupId the group ID
13135             * @param status the status
13136             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13137             * @return the first matching journal article
13138             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13139             * @throws SystemException if a system exception occurred
13140             */
13141            public JournalArticle findByG_ST_First(long groupId, int status,
13142                    OrderByComparator orderByComparator)
13143                    throws NoSuchArticleException, SystemException {
13144                    JournalArticle journalArticle = fetchByG_ST_First(groupId, status,
13145                                    orderByComparator);
13146    
13147                    if (journalArticle != null) {
13148                            return journalArticle;
13149                    }
13150    
13151                    StringBundler msg = new StringBundler(6);
13152    
13153                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13154    
13155                    msg.append("groupId=");
13156                    msg.append(groupId);
13157    
13158                    msg.append(", status=");
13159                    msg.append(status);
13160    
13161                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13162    
13163                    throw new NoSuchArticleException(msg.toString());
13164            }
13165    
13166            /**
13167             * Returns the first journal article in the ordered set where groupId = &#63; and status = &#63;.
13168             *
13169             * @param groupId the group ID
13170             * @param status the status
13171             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13172             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
13173             * @throws SystemException if a system exception occurred
13174             */
13175            public JournalArticle fetchByG_ST_First(long groupId, int status,
13176                    OrderByComparator orderByComparator) throws SystemException {
13177                    List<JournalArticle> list = findByG_ST(groupId, status, 0, 1,
13178                                    orderByComparator);
13179    
13180                    if (!list.isEmpty()) {
13181                            return list.get(0);
13182                    }
13183    
13184                    return null;
13185            }
13186    
13187            /**
13188             * Returns the last journal article in the ordered set where groupId = &#63; and status = &#63;.
13189             *
13190             * @param groupId the group ID
13191             * @param status the status
13192             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13193             * @return the last matching journal article
13194             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13195             * @throws SystemException if a system exception occurred
13196             */
13197            public JournalArticle findByG_ST_Last(long groupId, int status,
13198                    OrderByComparator orderByComparator)
13199                    throws NoSuchArticleException, SystemException {
13200                    JournalArticle journalArticle = fetchByG_ST_Last(groupId, status,
13201                                    orderByComparator);
13202    
13203                    if (journalArticle != null) {
13204                            return journalArticle;
13205                    }
13206    
13207                    StringBundler msg = new StringBundler(6);
13208    
13209                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13210    
13211                    msg.append("groupId=");
13212                    msg.append(groupId);
13213    
13214                    msg.append(", status=");
13215                    msg.append(status);
13216    
13217                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13218    
13219                    throw new NoSuchArticleException(msg.toString());
13220            }
13221    
13222            /**
13223             * Returns the last journal article in the ordered set where groupId = &#63; and status = &#63;.
13224             *
13225             * @param groupId the group ID
13226             * @param status the status
13227             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13228             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
13229             * @throws SystemException if a system exception occurred
13230             */
13231            public JournalArticle fetchByG_ST_Last(long groupId, int status,
13232                    OrderByComparator orderByComparator) throws SystemException {
13233                    int count = countByG_ST(groupId, status);
13234    
13235                    List<JournalArticle> list = findByG_ST(groupId, status, count - 1,
13236                                    count, orderByComparator);
13237    
13238                    if (!list.isEmpty()) {
13239                            return list.get(0);
13240                    }
13241    
13242                    return null;
13243            }
13244    
13245            /**
13246             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and status = &#63;.
13247             *
13248             * @param id the primary key of the current journal article
13249             * @param groupId the group ID
13250             * @param status the status
13251             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13252             * @return the previous, current, and next journal article
13253             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13254             * @throws SystemException if a system exception occurred
13255             */
13256            public JournalArticle[] findByG_ST_PrevAndNext(long id, long groupId,
13257                    int status, OrderByComparator orderByComparator)
13258                    throws NoSuchArticleException, SystemException {
13259                    JournalArticle journalArticle = findByPrimaryKey(id);
13260    
13261                    Session session = null;
13262    
13263                    try {
13264                            session = openSession();
13265    
13266                            JournalArticle[] array = new JournalArticleImpl[3];
13267    
13268                            array[0] = getByG_ST_PrevAndNext(session, journalArticle, groupId,
13269                                            status, orderByComparator, true);
13270    
13271                            array[1] = journalArticle;
13272    
13273                            array[2] = getByG_ST_PrevAndNext(session, journalArticle, groupId,
13274                                            status, orderByComparator, false);
13275    
13276                            return array;
13277                    }
13278                    catch (Exception e) {
13279                            throw processException(e);
13280                    }
13281                    finally {
13282                            closeSession(session);
13283                    }
13284            }
13285    
13286            protected JournalArticle getByG_ST_PrevAndNext(Session session,
13287                    JournalArticle journalArticle, long groupId, int status,
13288                    OrderByComparator orderByComparator, boolean previous) {
13289                    StringBundler query = null;
13290    
13291                    if (orderByComparator != null) {
13292                            query = new StringBundler(6 +
13293                                            (orderByComparator.getOrderByFields().length * 6));
13294                    }
13295                    else {
13296                            query = new StringBundler(3);
13297                    }
13298    
13299                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13300    
13301                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
13302    
13303                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
13304    
13305                    if (orderByComparator != null) {
13306                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13307    
13308                            if (orderByConditionFields.length > 0) {
13309                                    query.append(WHERE_AND);
13310                            }
13311    
13312                            for (int i = 0; i < orderByConditionFields.length; i++) {
13313                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13314                                    query.append(orderByConditionFields[i]);
13315    
13316                                    if ((i + 1) < orderByConditionFields.length) {
13317                                            if (orderByComparator.isAscending() ^ previous) {
13318                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13319                                            }
13320                                            else {
13321                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13322                                            }
13323                                    }
13324                                    else {
13325                                            if (orderByComparator.isAscending() ^ previous) {
13326                                                    query.append(WHERE_GREATER_THAN);
13327                                            }
13328                                            else {
13329                                                    query.append(WHERE_LESSER_THAN);
13330                                            }
13331                                    }
13332                            }
13333    
13334                            query.append(ORDER_BY_CLAUSE);
13335    
13336                            String[] orderByFields = orderByComparator.getOrderByFields();
13337    
13338                            for (int i = 0; i < orderByFields.length; i++) {
13339                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13340                                    query.append(orderByFields[i]);
13341    
13342                                    if ((i + 1) < orderByFields.length) {
13343                                            if (orderByComparator.isAscending() ^ previous) {
13344                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13345                                            }
13346                                            else {
13347                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13348                                            }
13349                                    }
13350                                    else {
13351                                            if (orderByComparator.isAscending() ^ previous) {
13352                                                    query.append(ORDER_BY_ASC);
13353                                            }
13354                                            else {
13355                                                    query.append(ORDER_BY_DESC);
13356                                            }
13357                                    }
13358                            }
13359                    }
13360                    else {
13361                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13362                    }
13363    
13364                    String sql = query.toString();
13365    
13366                    Query q = session.createQuery(sql);
13367    
13368                    q.setFirstResult(0);
13369                    q.setMaxResults(2);
13370    
13371                    QueryPos qPos = QueryPos.getInstance(q);
13372    
13373                    qPos.add(groupId);
13374    
13375                    qPos.add(status);
13376    
13377                    if (orderByComparator != null) {
13378                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13379    
13380                            for (Object value : values) {
13381                                    qPos.add(value);
13382                            }
13383                    }
13384    
13385                    List<JournalArticle> list = q.list();
13386    
13387                    if (list.size() == 2) {
13388                            return list.get(1);
13389                    }
13390                    else {
13391                            return null;
13392                    }
13393            }
13394    
13395            /**
13396             * Returns all the journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
13397             *
13398             * @param groupId the group ID
13399             * @param status the status
13400             * @return the matching journal articles that the user has permission to view
13401             * @throws SystemException if a system exception occurred
13402             */
13403            public List<JournalArticle> filterFindByG_ST(long groupId, int status)
13404                    throws SystemException {
13405                    return filterFindByG_ST(groupId, status, QueryUtil.ALL_POS,
13406                            QueryUtil.ALL_POS, null);
13407            }
13408    
13409            /**
13410             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
13411             *
13412             * <p>
13413             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13414             * </p>
13415             *
13416             * @param groupId the group ID
13417             * @param status the status
13418             * @param start the lower bound of the range of journal articles
13419             * @param end the upper bound of the range of journal articles (not inclusive)
13420             * @return the range of matching journal articles that the user has permission to view
13421             * @throws SystemException if a system exception occurred
13422             */
13423            public List<JournalArticle> filterFindByG_ST(long groupId, int status,
13424                    int start, int end) throws SystemException {
13425                    return filterFindByG_ST(groupId, status, start, end, null);
13426            }
13427    
13428            /**
13429             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and status = &#63;.
13430             *
13431             * <p>
13432             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13433             * </p>
13434             *
13435             * @param groupId the group ID
13436             * @param status the status
13437             * @param start the lower bound of the range of journal articles
13438             * @param end the upper bound of the range of journal articles (not inclusive)
13439             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13440             * @return the ordered range of matching journal articles that the user has permission to view
13441             * @throws SystemException if a system exception occurred
13442             */
13443            public List<JournalArticle> filterFindByG_ST(long groupId, int status,
13444                    int start, int end, OrderByComparator orderByComparator)
13445                    throws SystemException {
13446                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13447                            return findByG_ST(groupId, status, start, end, orderByComparator);
13448                    }
13449    
13450                    StringBundler query = null;
13451    
13452                    if (orderByComparator != null) {
13453                            query = new StringBundler(4 +
13454                                            (orderByComparator.getOrderByFields().length * 3));
13455                    }
13456                    else {
13457                            query = new StringBundler(4);
13458                    }
13459    
13460                    if (getDB().isSupportsInlineDistinct()) {
13461                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
13462                    }
13463                    else {
13464                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
13465                    }
13466    
13467                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
13468    
13469                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
13470    
13471                    if (!getDB().isSupportsInlineDistinct()) {
13472                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
13473                    }
13474    
13475                    if (orderByComparator != null) {
13476                            if (getDB().isSupportsInlineDistinct()) {
13477                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13478                                            orderByComparator);
13479                            }
13480                            else {
13481                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
13482                                            orderByComparator);
13483                            }
13484                    }
13485                    else {
13486                            if (getDB().isSupportsInlineDistinct()) {
13487                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13488                            }
13489                            else {
13490                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
13491                            }
13492                    }
13493    
13494                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13495                                    JournalArticle.class.getName(),
13496                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13497    
13498                    Session session = null;
13499    
13500                    try {
13501                            session = openSession();
13502    
13503                            SQLQuery q = session.createSQLQuery(sql);
13504    
13505                            if (getDB().isSupportsInlineDistinct()) {
13506                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
13507                            }
13508                            else {
13509                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
13510                            }
13511    
13512                            QueryPos qPos = QueryPos.getInstance(q);
13513    
13514                            qPos.add(groupId);
13515    
13516                            qPos.add(status);
13517    
13518                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
13519                                    end);
13520                    }
13521                    catch (Exception e) {
13522                            throw processException(e);
13523                    }
13524                    finally {
13525                            closeSession(session);
13526                    }
13527            }
13528    
13529            /**
13530             * 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;.
13531             *
13532             * @param id the primary key of the current journal article
13533             * @param groupId the group ID
13534             * @param status the status
13535             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13536             * @return the previous, current, and next journal article
13537             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13538             * @throws SystemException if a system exception occurred
13539             */
13540            public JournalArticle[] filterFindByG_ST_PrevAndNext(long id, long groupId,
13541                    int status, OrderByComparator orderByComparator)
13542                    throws NoSuchArticleException, SystemException {
13543                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13544                            return findByG_ST_PrevAndNext(id, groupId, status, orderByComparator);
13545                    }
13546    
13547                    JournalArticle journalArticle = findByPrimaryKey(id);
13548    
13549                    Session session = null;
13550    
13551                    try {
13552                            session = openSession();
13553    
13554                            JournalArticle[] array = new JournalArticleImpl[3];
13555    
13556                            array[0] = filterGetByG_ST_PrevAndNext(session, journalArticle,
13557                                            groupId, status, orderByComparator, true);
13558    
13559                            array[1] = journalArticle;
13560    
13561                            array[2] = filterGetByG_ST_PrevAndNext(session, journalArticle,
13562                                            groupId, status, orderByComparator, false);
13563    
13564                            return array;
13565                    }
13566                    catch (Exception e) {
13567                            throw processException(e);
13568                    }
13569                    finally {
13570                            closeSession(session);
13571                    }
13572            }
13573    
13574            protected JournalArticle filterGetByG_ST_PrevAndNext(Session session,
13575                    JournalArticle journalArticle, long groupId, int status,
13576                    OrderByComparator orderByComparator, boolean previous) {
13577                    StringBundler query = null;
13578    
13579                    if (orderByComparator != null) {
13580                            query = new StringBundler(6 +
13581                                            (orderByComparator.getOrderByFields().length * 6));
13582                    }
13583                    else {
13584                            query = new StringBundler(3);
13585                    }
13586    
13587                    if (getDB().isSupportsInlineDistinct()) {
13588                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
13589                    }
13590                    else {
13591                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
13592                    }
13593    
13594                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
13595    
13596                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
13597    
13598                    if (!getDB().isSupportsInlineDistinct()) {
13599                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
13600                    }
13601    
13602                    if (orderByComparator != null) {
13603                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13604    
13605                            if (orderByConditionFields.length > 0) {
13606                                    query.append(WHERE_AND);
13607                            }
13608    
13609                            for (int i = 0; i < orderByConditionFields.length; i++) {
13610                                    if (getDB().isSupportsInlineDistinct()) {
13611                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13612                                    }
13613                                    else {
13614                                            query.append(_ORDER_BY_ENTITY_TABLE);
13615                                    }
13616    
13617                                    query.append(orderByConditionFields[i]);
13618    
13619                                    if ((i + 1) < orderByConditionFields.length) {
13620                                            if (orderByComparator.isAscending() ^ previous) {
13621                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13622                                            }
13623                                            else {
13624                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13625                                            }
13626                                    }
13627                                    else {
13628                                            if (orderByComparator.isAscending() ^ previous) {
13629                                                    query.append(WHERE_GREATER_THAN);
13630                                            }
13631                                            else {
13632                                                    query.append(WHERE_LESSER_THAN);
13633                                            }
13634                                    }
13635                            }
13636    
13637                            query.append(ORDER_BY_CLAUSE);
13638    
13639                            String[] orderByFields = orderByComparator.getOrderByFields();
13640    
13641                            for (int i = 0; i < orderByFields.length; i++) {
13642                                    if (getDB().isSupportsInlineDistinct()) {
13643                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13644                                    }
13645                                    else {
13646                                            query.append(_ORDER_BY_ENTITY_TABLE);
13647                                    }
13648    
13649                                    query.append(orderByFields[i]);
13650    
13651                                    if ((i + 1) < orderByFields.length) {
13652                                            if (orderByComparator.isAscending() ^ previous) {
13653                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13654                                            }
13655                                            else {
13656                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13657                                            }
13658                                    }
13659                                    else {
13660                                            if (orderByComparator.isAscending() ^ previous) {
13661                                                    query.append(ORDER_BY_ASC);
13662                                            }
13663                                            else {
13664                                                    query.append(ORDER_BY_DESC);
13665                                            }
13666                                    }
13667                            }
13668                    }
13669                    else {
13670                            if (getDB().isSupportsInlineDistinct()) {
13671                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13672                            }
13673                            else {
13674                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
13675                            }
13676                    }
13677    
13678                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13679                                    JournalArticle.class.getName(),
13680                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13681    
13682                    SQLQuery q = session.createSQLQuery(sql);
13683    
13684                    q.setFirstResult(0);
13685                    q.setMaxResults(2);
13686    
13687                    if (getDB().isSupportsInlineDistinct()) {
13688                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
13689                    }
13690                    else {
13691                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
13692                    }
13693    
13694                    QueryPos qPos = QueryPos.getInstance(q);
13695    
13696                    qPos.add(groupId);
13697    
13698                    qPos.add(status);
13699    
13700                    if (orderByComparator != null) {
13701                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13702    
13703                            for (Object value : values) {
13704                                    qPos.add(value);
13705                            }
13706                    }
13707    
13708                    List<JournalArticle> list = q.list();
13709    
13710                    if (list.size() == 2) {
13711                            return list.get(1);
13712                    }
13713                    else {
13714                            return null;
13715                    }
13716            }
13717    
13718            /**
13719             * Removes all the journal articles where groupId = &#63; and status = &#63; from the database.
13720             *
13721             * @param groupId the group ID
13722             * @param status the status
13723             * @throws SystemException if a system exception occurred
13724             */
13725            public void removeByG_ST(long groupId, int status)
13726                    throws SystemException {
13727                    for (JournalArticle journalArticle : findByG_ST(groupId, status,
13728                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
13729                            remove(journalArticle);
13730                    }
13731            }
13732    
13733            /**
13734             * Returns the number of journal articles where groupId = &#63; and status = &#63;.
13735             *
13736             * @param groupId the group ID
13737             * @param status the status
13738             * @return the number of matching journal articles
13739             * @throws SystemException if a system exception occurred
13740             */
13741            public int countByG_ST(long groupId, int status) throws SystemException {
13742                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_ST;
13743    
13744                    Object[] finderArgs = new Object[] { groupId, status };
13745    
13746                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
13747                                    this);
13748    
13749                    if (count == null) {
13750                            StringBundler query = new StringBundler(3);
13751    
13752                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
13753    
13754                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
13755    
13756                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
13757    
13758                            String sql = query.toString();
13759    
13760                            Session session = null;
13761    
13762                            try {
13763                                    session = openSession();
13764    
13765                                    Query q = session.createQuery(sql);
13766    
13767                                    QueryPos qPos = QueryPos.getInstance(q);
13768    
13769                                    qPos.add(groupId);
13770    
13771                                    qPos.add(status);
13772    
13773                                    count = (Long)q.uniqueResult();
13774    
13775                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
13776                            }
13777                            catch (Exception e) {
13778                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13779    
13780                                    throw processException(e);
13781                            }
13782                            finally {
13783                                    closeSession(session);
13784                            }
13785                    }
13786    
13787                    return count.intValue();
13788            }
13789    
13790            /**
13791             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
13792             *
13793             * @param groupId the group ID
13794             * @param status the status
13795             * @return the number of matching journal articles that the user has permission to view
13796             * @throws SystemException if a system exception occurred
13797             */
13798            public int filterCountByG_ST(long groupId, int status)
13799                    throws SystemException {
13800                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13801                            return countByG_ST(groupId, status);
13802                    }
13803    
13804                    StringBundler query = new StringBundler(3);
13805    
13806                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
13807    
13808                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
13809    
13810                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
13811    
13812                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13813                                    JournalArticle.class.getName(),
13814                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13815    
13816                    Session session = null;
13817    
13818                    try {
13819                            session = openSession();
13820    
13821                            SQLQuery q = session.createSQLQuery(sql);
13822    
13823                            q.addScalar(COUNT_COLUMN_NAME,
13824                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
13825    
13826                            QueryPos qPos = QueryPos.getInstance(q);
13827    
13828                            qPos.add(groupId);
13829    
13830                            qPos.add(status);
13831    
13832                            Long count = (Long)q.uniqueResult();
13833    
13834                            return count.intValue();
13835                    }
13836                    catch (Exception e) {
13837                            throw processException(e);
13838                    }
13839                    finally {
13840                            closeSession(session);
13841                    }
13842            }
13843    
13844            private static final String _FINDER_COLUMN_G_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
13845            private static final String _FINDER_COLUMN_G_ST_STATUS_2 = "journalArticle.status = ?";
13846            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13847                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
13848                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
13849                            "findByC_V",
13850                            new String[] {
13851                                    Long.class.getName(), Double.class.getName(),
13852                                    
13853                            Integer.class.getName(), Integer.class.getName(),
13854                                    OrderByComparator.class.getName()
13855                            });
13856            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13857                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
13858                            JournalArticleImpl.class,
13859                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_V",
13860                            new String[] { Long.class.getName(), Double.class.getName() },
13861                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
13862                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK |
13863                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK);
13864            public static final FinderPath FINDER_PATH_COUNT_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13865                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
13866                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_V",
13867                            new String[] { Long.class.getName(), Double.class.getName() });
13868    
13869            /**
13870             * Returns all the journal articles where companyId = &#63; and version = &#63;.
13871             *
13872             * @param companyId the company ID
13873             * @param version the version
13874             * @return the matching journal articles
13875             * @throws SystemException if a system exception occurred
13876             */
13877            public List<JournalArticle> findByC_V(long companyId, double version)
13878                    throws SystemException {
13879                    return findByC_V(companyId, version, QueryUtil.ALL_POS,
13880                            QueryUtil.ALL_POS, null);
13881            }
13882    
13883            /**
13884             * Returns a range of all the journal articles where companyId = &#63; and version = &#63;.
13885             *
13886             * <p>
13887             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13888             * </p>
13889             *
13890             * @param companyId the company ID
13891             * @param version the version
13892             * @param start the lower bound of the range of journal articles
13893             * @param end the upper bound of the range of journal articles (not inclusive)
13894             * @return the range of matching journal articles
13895             * @throws SystemException if a system exception occurred
13896             */
13897            public List<JournalArticle> findByC_V(long companyId, double version,
13898                    int start, int end) throws SystemException {
13899                    return findByC_V(companyId, version, start, end, null);
13900            }
13901    
13902            /**
13903             * Returns an ordered range of all the journal articles where companyId = &#63; and version = &#63;.
13904             *
13905             * <p>
13906             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13907             * </p>
13908             *
13909             * @param companyId the company ID
13910             * @param version the version
13911             * @param start the lower bound of the range of journal articles
13912             * @param end the upper bound of the range of journal articles (not inclusive)
13913             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13914             * @return the ordered range of matching journal articles
13915             * @throws SystemException if a system exception occurred
13916             */
13917            public List<JournalArticle> findByC_V(long companyId, double version,
13918                    int start, int end, OrderByComparator orderByComparator)
13919                    throws SystemException {
13920                    boolean pagination = true;
13921                    FinderPath finderPath = null;
13922                    Object[] finderArgs = null;
13923    
13924                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13925                                    (orderByComparator == null)) {
13926                            pagination = false;
13927                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V;
13928                            finderArgs = new Object[] { companyId, version };
13929                    }
13930                    else {
13931                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V;
13932                            finderArgs = new Object[] {
13933                                            companyId, version,
13934                                            
13935                                            start, end, orderByComparator
13936                                    };
13937                    }
13938    
13939                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
13940                                    finderArgs, this);
13941    
13942                    if ((list != null) && !list.isEmpty()) {
13943                            for (JournalArticle journalArticle : list) {
13944                                    if ((companyId != journalArticle.getCompanyId()) ||
13945                                                    (version != journalArticle.getVersion())) {
13946                                            list = null;
13947    
13948                                            break;
13949                                    }
13950                            }
13951                    }
13952    
13953                    if (list == null) {
13954                            StringBundler query = null;
13955    
13956                            if (orderByComparator != null) {
13957                                    query = new StringBundler(4 +
13958                                                    (orderByComparator.getOrderByFields().length * 3));
13959                            }
13960                            else {
13961                                    query = new StringBundler(4);
13962                            }
13963    
13964                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13965    
13966                            query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
13967    
13968                            query.append(_FINDER_COLUMN_C_V_VERSION_2);
13969    
13970                            if (orderByComparator != null) {
13971                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13972                                            orderByComparator);
13973                            }
13974                            else
13975                             if (pagination) {
13976                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13977                            }
13978    
13979                            String sql = query.toString();
13980    
13981                            Session session = null;
13982    
13983                            try {
13984                                    session = openSession();
13985    
13986                                    Query q = session.createQuery(sql);
13987    
13988                                    QueryPos qPos = QueryPos.getInstance(q);
13989    
13990                                    qPos.add(companyId);
13991    
13992                                    qPos.add(version);
13993    
13994                                    if (!pagination) {
13995                                            list = (List<JournalArticle>)QueryUtil.list(q,
13996                                                            getDialect(), start, end, false);
13997    
13998                                            Collections.sort(list);
13999    
14000                                            list = new UnmodifiableList<JournalArticle>(list);
14001                                    }
14002                                    else {
14003                                            list = (List<JournalArticle>)QueryUtil.list(q,
14004                                                            getDialect(), start, end);
14005                                    }
14006    
14007                                    cacheResult(list);
14008    
14009                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
14010                            }
14011                            catch (Exception e) {
14012                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14013    
14014                                    throw processException(e);
14015                            }
14016                            finally {
14017                                    closeSession(session);
14018                            }
14019                    }
14020    
14021                    return list;
14022            }
14023    
14024            /**
14025             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63;.
14026             *
14027             * @param companyId the company ID
14028             * @param version the version
14029             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14030             * @return the first matching journal article
14031             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
14032             * @throws SystemException if a system exception occurred
14033             */
14034            public JournalArticle findByC_V_First(long companyId, double version,
14035                    OrderByComparator orderByComparator)
14036                    throws NoSuchArticleException, SystemException {
14037                    JournalArticle journalArticle = fetchByC_V_First(companyId, version,
14038                                    orderByComparator);
14039    
14040                    if (journalArticle != null) {
14041                            return journalArticle;
14042                    }
14043    
14044                    StringBundler msg = new StringBundler(6);
14045    
14046                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14047    
14048                    msg.append("companyId=");
14049                    msg.append(companyId);
14050    
14051                    msg.append(", version=");
14052                    msg.append(version);
14053    
14054                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14055    
14056                    throw new NoSuchArticleException(msg.toString());
14057            }
14058    
14059            /**
14060             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63;.
14061             *
14062             * @param companyId the company ID
14063             * @param version the version
14064             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14065             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
14066             * @throws SystemException if a system exception occurred
14067             */
14068            public JournalArticle fetchByC_V_First(long companyId, double version,
14069                    OrderByComparator orderByComparator) throws SystemException {
14070                    List<JournalArticle> list = findByC_V(companyId, version, 0, 1,
14071                                    orderByComparator);
14072    
14073                    if (!list.isEmpty()) {
14074                            return list.get(0);
14075                    }
14076    
14077                    return null;
14078            }
14079    
14080            /**
14081             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63;.
14082             *
14083             * @param companyId the company ID
14084             * @param version the version
14085             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14086             * @return the last matching journal article
14087             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
14088             * @throws SystemException if a system exception occurred
14089             */
14090            public JournalArticle findByC_V_Last(long companyId, double version,
14091                    OrderByComparator orderByComparator)
14092                    throws NoSuchArticleException, SystemException {
14093                    JournalArticle journalArticle = fetchByC_V_Last(companyId, version,
14094                                    orderByComparator);
14095    
14096                    if (journalArticle != null) {
14097                            return journalArticle;
14098                    }
14099    
14100                    StringBundler msg = new StringBundler(6);
14101    
14102                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14103    
14104                    msg.append("companyId=");
14105                    msg.append(companyId);
14106    
14107                    msg.append(", version=");
14108                    msg.append(version);
14109    
14110                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14111    
14112                    throw new NoSuchArticleException(msg.toString());
14113            }
14114    
14115            /**
14116             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63;.
14117             *
14118             * @param companyId the company ID
14119             * @param version the version
14120             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14121             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
14122             * @throws SystemException if a system exception occurred
14123             */
14124            public JournalArticle fetchByC_V_Last(long companyId, double version,
14125                    OrderByComparator orderByComparator) throws SystemException {
14126                    int count = countByC_V(companyId, version);
14127    
14128                    List<JournalArticle> list = findByC_V(companyId, version, count - 1,
14129                                    count, orderByComparator);
14130    
14131                    if (!list.isEmpty()) {
14132                            return list.get(0);
14133                    }
14134    
14135                    return null;
14136            }
14137    
14138            /**
14139             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and version = &#63;.
14140             *
14141             * @param id the primary key of the current journal article
14142             * @param companyId the company ID
14143             * @param version the version
14144             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14145             * @return the previous, current, and next journal article
14146             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
14147             * @throws SystemException if a system exception occurred
14148             */
14149            public JournalArticle[] findByC_V_PrevAndNext(long id, long companyId,
14150                    double version, OrderByComparator orderByComparator)
14151                    throws NoSuchArticleException, SystemException {
14152                    JournalArticle journalArticle = findByPrimaryKey(id);
14153    
14154                    Session session = null;
14155    
14156                    try {
14157                            session = openSession();
14158    
14159                            JournalArticle[] array = new JournalArticleImpl[3];
14160    
14161                            array[0] = getByC_V_PrevAndNext(session, journalArticle, companyId,
14162                                            version, orderByComparator, true);
14163    
14164                            array[1] = journalArticle;
14165    
14166                            array[2] = getByC_V_PrevAndNext(session, journalArticle, companyId,
14167                                            version, orderByComparator, false);
14168    
14169                            return array;
14170                    }
14171                    catch (Exception e) {
14172                            throw processException(e);
14173                    }
14174                    finally {
14175                            closeSession(session);
14176                    }
14177            }
14178    
14179            protected JournalArticle getByC_V_PrevAndNext(Session session,
14180                    JournalArticle journalArticle, long companyId, double version,
14181                    OrderByComparator orderByComparator, boolean previous) {
14182                    StringBundler query = null;
14183    
14184                    if (orderByComparator != null) {
14185                            query = new StringBundler(6 +
14186                                            (orderByComparator.getOrderByFields().length * 6));
14187                    }
14188                    else {
14189                            query = new StringBundler(3);
14190                    }
14191    
14192                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
14193    
14194                    query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
14195    
14196                    query.append(_FINDER_COLUMN_C_V_VERSION_2);
14197    
14198                    if (orderByComparator != null) {
14199                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14200    
14201                            if (orderByConditionFields.length > 0) {
14202                                    query.append(WHERE_AND);
14203                            }
14204    
14205                            for (int i = 0; i < orderByConditionFields.length; i++) {
14206                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14207                                    query.append(orderByConditionFields[i]);
14208    
14209                                    if ((i + 1) < orderByConditionFields.length) {
14210                                            if (orderByComparator.isAscending() ^ previous) {
14211                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14212                                            }
14213                                            else {
14214                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14215                                            }
14216                                    }
14217                                    else {
14218                                            if (orderByComparator.isAscending() ^ previous) {
14219                                                    query.append(WHERE_GREATER_THAN);
14220                                            }
14221                                            else {
14222                                                    query.append(WHERE_LESSER_THAN);
14223                                            }
14224                                    }
14225                            }
14226    
14227                            query.append(ORDER_BY_CLAUSE);
14228    
14229                            String[] orderByFields = orderByComparator.getOrderByFields();
14230    
14231                            for (int i = 0; i < orderByFields.length; i++) {
14232                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14233                                    query.append(orderByFields[i]);
14234    
14235                                    if ((i + 1) < orderByFields.length) {
14236                                            if (orderByComparator.isAscending() ^ previous) {
14237                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14238                                            }
14239                                            else {
14240                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14241                                            }
14242                                    }
14243                                    else {
14244                                            if (orderByComparator.isAscending() ^ previous) {
14245                                                    query.append(ORDER_BY_ASC);
14246                                            }
14247                                            else {
14248                                                    query.append(ORDER_BY_DESC);
14249                                            }
14250                                    }
14251                            }
14252                    }
14253                    else {
14254                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14255                    }
14256    
14257                    String sql = query.toString();
14258    
14259                    Query q = session.createQuery(sql);
14260    
14261                    q.setFirstResult(0);
14262                    q.setMaxResults(2);
14263    
14264                    QueryPos qPos = QueryPos.getInstance(q);
14265    
14266                    qPos.add(companyId);
14267    
14268                    qPos.add(version);
14269    
14270                    if (orderByComparator != null) {
14271                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
14272    
14273                            for (Object value : values) {
14274                                    qPos.add(value);
14275                            }
14276                    }
14277    
14278                    List<JournalArticle> list = q.list();
14279    
14280                    if (list.size() == 2) {
14281                            return list.get(1);
14282                    }
14283                    else {
14284                            return null;
14285                    }
14286            }
14287    
14288            /**
14289             * Removes all the journal articles where companyId = &#63; and version = &#63; from the database.
14290             *
14291             * @param companyId the company ID
14292             * @param version the version
14293             * @throws SystemException if a system exception occurred
14294             */
14295            public void removeByC_V(long companyId, double version)
14296                    throws SystemException {
14297                    for (JournalArticle journalArticle : findByC_V(companyId, version,
14298                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14299                            remove(journalArticle);
14300                    }
14301            }
14302    
14303            /**
14304             * Returns the number of journal articles where companyId = &#63; and version = &#63;.
14305             *
14306             * @param companyId the company ID
14307             * @param version the version
14308             * @return the number of matching journal articles
14309             * @throws SystemException if a system exception occurred
14310             */
14311            public int countByC_V(long companyId, double version)
14312                    throws SystemException {
14313                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_V;
14314    
14315                    Object[] finderArgs = new Object[] { companyId, version };
14316    
14317                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
14318                                    this);
14319    
14320                    if (count == null) {
14321                            StringBundler query = new StringBundler(3);
14322    
14323                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14324    
14325                            query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
14326    
14327                            query.append(_FINDER_COLUMN_C_V_VERSION_2);
14328    
14329                            String sql = query.toString();
14330    
14331                            Session session = null;
14332    
14333                            try {
14334                                    session = openSession();
14335    
14336                                    Query q = session.createQuery(sql);
14337    
14338                                    QueryPos qPos = QueryPos.getInstance(q);
14339    
14340                                    qPos.add(companyId);
14341    
14342                                    qPos.add(version);
14343    
14344                                    count = (Long)q.uniqueResult();
14345    
14346                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
14347                            }
14348                            catch (Exception e) {
14349                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14350    
14351                                    throw processException(e);
14352                            }
14353                            finally {
14354                                    closeSession(session);
14355                            }
14356                    }
14357    
14358                    return count.intValue();
14359            }
14360    
14361            private static final String _FINDER_COLUMN_C_V_COMPANYID_2 = "journalArticle.companyId = ? AND ";
14362            private static final String _FINDER_COLUMN_C_V_VERSION_2 = "journalArticle.version = ?";
14363            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14364                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
14365                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
14366                            "findByC_ST",
14367                            new String[] {
14368                                    Long.class.getName(), Integer.class.getName(),
14369                                    
14370                            Integer.class.getName(), Integer.class.getName(),
14371                                    OrderByComparator.class.getName()
14372                            });
14373            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14374                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
14375                            JournalArticleImpl.class,
14376                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_ST",
14377                            new String[] { Long.class.getName(), Integer.class.getName() },
14378                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
14379                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
14380                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
14381                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
14382            public static final FinderPath FINDER_PATH_COUNT_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14383                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
14384                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_ST",
14385                            new String[] { Long.class.getName(), Integer.class.getName() });
14386    
14387            /**
14388             * Returns all the journal articles where companyId = &#63; and status = &#63;.
14389             *
14390             * @param companyId the company ID
14391             * @param status the status
14392             * @return the matching journal articles
14393             * @throws SystemException if a system exception occurred
14394             */
14395            public List<JournalArticle> findByC_ST(long companyId, int status)
14396                    throws SystemException {
14397                    return findByC_ST(companyId, status, QueryUtil.ALL_POS,
14398                            QueryUtil.ALL_POS, null);
14399            }
14400    
14401            /**
14402             * Returns a range of all the journal articles where companyId = &#63; and status = &#63;.
14403             *
14404             * <p>
14405             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14406             * </p>
14407             *
14408             * @param companyId the company ID
14409             * @param status the status
14410             * @param start the lower bound of the range of journal articles
14411             * @param end the upper bound of the range of journal articles (not inclusive)
14412             * @return the range of matching journal articles
14413             * @throws SystemException if a system exception occurred
14414             */
14415            public List<JournalArticle> findByC_ST(long companyId, int status,
14416                    int start, int end) throws SystemException {
14417                    return findByC_ST(companyId, status, start, end, null);
14418            }
14419    
14420            /**
14421             * Returns an ordered range of all the journal articles where companyId = &#63; and status = &#63;.
14422             *
14423             * <p>
14424             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14425             * </p>
14426             *
14427             * @param companyId the company ID
14428             * @param status the status
14429             * @param start the lower bound of the range of journal articles
14430             * @param end the upper bound of the range of journal articles (not inclusive)
14431             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14432             * @return the ordered range of matching journal articles
14433             * @throws SystemException if a system exception occurred
14434             */
14435            public List<JournalArticle> findByC_ST(long companyId, int status,
14436                    int start, int end, OrderByComparator orderByComparator)
14437                    throws SystemException {
14438                    boolean pagination = true;
14439                    FinderPath finderPath = null;
14440                    Object[] finderArgs = null;
14441    
14442                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
14443                                    (orderByComparator == null)) {
14444                            pagination = false;
14445                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST;
14446                            finderArgs = new Object[] { companyId, status };
14447                    }
14448                    else {
14449                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_ST;
14450                            finderArgs = new Object[] {
14451                                            companyId, status,
14452                                            
14453                                            start, end, orderByComparator
14454                                    };
14455                    }
14456    
14457                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
14458                                    finderArgs, this);
14459    
14460                    if ((list != null) && !list.isEmpty()) {
14461                            for (JournalArticle journalArticle : list) {
14462                                    if ((companyId != journalArticle.getCompanyId()) ||
14463                                                    (status != journalArticle.getStatus())) {
14464                                            list = null;
14465    
14466                                            break;
14467                                    }
14468                            }
14469                    }
14470    
14471                    if (list == null) {
14472                            StringBundler query = null;
14473    
14474                            if (orderByComparator != null) {
14475                                    query = new StringBundler(4 +
14476                                                    (orderByComparator.getOrderByFields().length * 3));
14477                            }
14478                            else {
14479                                    query = new StringBundler(4);
14480                            }
14481    
14482                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
14483    
14484                            query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
14485    
14486                            query.append(_FINDER_COLUMN_C_ST_STATUS_2);
14487    
14488                            if (orderByComparator != null) {
14489                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14490                                            orderByComparator);
14491                            }
14492                            else
14493                             if (pagination) {
14494                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14495                            }
14496    
14497                            String sql = query.toString();
14498    
14499                            Session session = null;
14500    
14501                            try {
14502                                    session = openSession();
14503    
14504                                    Query q = session.createQuery(sql);
14505    
14506                                    QueryPos qPos = QueryPos.getInstance(q);
14507    
14508                                    qPos.add(companyId);
14509    
14510                                    qPos.add(status);
14511    
14512                                    if (!pagination) {
14513                                            list = (List<JournalArticle>)QueryUtil.list(q,
14514                                                            getDialect(), start, end, false);
14515    
14516                                            Collections.sort(list);
14517    
14518                                            list = new UnmodifiableList<JournalArticle>(list);
14519                                    }
14520                                    else {
14521                                            list = (List<JournalArticle>)QueryUtil.list(q,
14522                                                            getDialect(), start, end);
14523                                    }
14524    
14525                                    cacheResult(list);
14526    
14527                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
14528                            }
14529                            catch (Exception e) {
14530                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14531    
14532                                    throw processException(e);
14533                            }
14534                            finally {
14535                                    closeSession(session);
14536                            }
14537                    }
14538    
14539                    return list;
14540            }
14541    
14542            /**
14543             * Returns the first journal article in the ordered set where companyId = &#63; and status = &#63;.
14544             *
14545             * @param companyId the company ID
14546             * @param status the status
14547             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14548             * @return the first matching journal article
14549             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
14550             * @throws SystemException if a system exception occurred
14551             */
14552            public JournalArticle findByC_ST_First(long companyId, int status,
14553                    OrderByComparator orderByComparator)
14554                    throws NoSuchArticleException, SystemException {
14555                    JournalArticle journalArticle = fetchByC_ST_First(companyId, status,
14556                                    orderByComparator);
14557    
14558                    if (journalArticle != null) {
14559                            return journalArticle;
14560                    }
14561    
14562                    StringBundler msg = new StringBundler(6);
14563    
14564                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14565    
14566                    msg.append("companyId=");
14567                    msg.append(companyId);
14568    
14569                    msg.append(", status=");
14570                    msg.append(status);
14571    
14572                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14573    
14574                    throw new NoSuchArticleException(msg.toString());
14575            }
14576    
14577            /**
14578             * Returns the first journal article in the ordered set where companyId = &#63; and status = &#63;.
14579             *
14580             * @param companyId the company ID
14581             * @param status the status
14582             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14583             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
14584             * @throws SystemException if a system exception occurred
14585             */
14586            public JournalArticle fetchByC_ST_First(long companyId, int status,
14587                    OrderByComparator orderByComparator) throws SystemException {
14588                    List<JournalArticle> list = findByC_ST(companyId, status, 0, 1,
14589                                    orderByComparator);
14590    
14591                    if (!list.isEmpty()) {
14592                            return list.get(0);
14593                    }
14594    
14595                    return null;
14596            }
14597    
14598            /**
14599             * Returns the last journal article in the ordered set where companyId = &#63; and status = &#63;.
14600             *
14601             * @param companyId the company ID
14602             * @param status the status
14603             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14604             * @return the last matching journal article
14605             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
14606             * @throws SystemException if a system exception occurred
14607             */
14608            public JournalArticle findByC_ST_Last(long companyId, int status,
14609                    OrderByComparator orderByComparator)
14610                    throws NoSuchArticleException, SystemException {
14611                    JournalArticle journalArticle = fetchByC_ST_Last(companyId, status,
14612                                    orderByComparator);
14613    
14614                    if (journalArticle != null) {
14615                            return journalArticle;
14616                    }
14617    
14618                    StringBundler msg = new StringBundler(6);
14619    
14620                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14621    
14622                    msg.append("companyId=");
14623                    msg.append(companyId);
14624    
14625                    msg.append(", status=");
14626                    msg.append(status);
14627    
14628                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14629    
14630                    throw new NoSuchArticleException(msg.toString());
14631            }
14632    
14633            /**
14634             * Returns the last journal article in the ordered set where companyId = &#63; and status = &#63;.
14635             *
14636             * @param companyId the company ID
14637             * @param status the status
14638             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14639             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
14640             * @throws SystemException if a system exception occurred
14641             */
14642            public JournalArticle fetchByC_ST_Last(long companyId, int status,
14643                    OrderByComparator orderByComparator) throws SystemException {
14644                    int count = countByC_ST(companyId, status);
14645    
14646                    List<JournalArticle> list = findByC_ST(companyId, status, count - 1,
14647                                    count, orderByComparator);
14648    
14649                    if (!list.isEmpty()) {
14650                            return list.get(0);
14651                    }
14652    
14653                    return null;
14654            }
14655    
14656            /**
14657             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and status = &#63;.
14658             *
14659             * @param id the primary key of the current journal article
14660             * @param companyId the company ID
14661             * @param status the status
14662             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14663             * @return the previous, current, and next journal article
14664             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
14665             * @throws SystemException if a system exception occurred
14666             */
14667            public JournalArticle[] findByC_ST_PrevAndNext(long id, long companyId,
14668                    int status, OrderByComparator orderByComparator)
14669                    throws NoSuchArticleException, SystemException {
14670                    JournalArticle journalArticle = findByPrimaryKey(id);
14671    
14672                    Session session = null;
14673    
14674                    try {
14675                            session = openSession();
14676    
14677                            JournalArticle[] array = new JournalArticleImpl[3];
14678    
14679                            array[0] = getByC_ST_PrevAndNext(session, journalArticle,
14680                                            companyId, status, orderByComparator, true);
14681    
14682                            array[1] = journalArticle;
14683    
14684                            array[2] = getByC_ST_PrevAndNext(session, journalArticle,
14685                                            companyId, status, orderByComparator, false);
14686    
14687                            return array;
14688                    }
14689                    catch (Exception e) {
14690                            throw processException(e);
14691                    }
14692                    finally {
14693                            closeSession(session);
14694                    }
14695            }
14696    
14697            protected JournalArticle getByC_ST_PrevAndNext(Session session,
14698                    JournalArticle journalArticle, long companyId, int status,
14699                    OrderByComparator orderByComparator, boolean previous) {
14700                    StringBundler query = null;
14701    
14702                    if (orderByComparator != null) {
14703                            query = new StringBundler(6 +
14704                                            (orderByComparator.getOrderByFields().length * 6));
14705                    }
14706                    else {
14707                            query = new StringBundler(3);
14708                    }
14709    
14710                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
14711    
14712                    query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
14713    
14714                    query.append(_FINDER_COLUMN_C_ST_STATUS_2);
14715    
14716                    if (orderByComparator != null) {
14717                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14718    
14719                            if (orderByConditionFields.length > 0) {
14720                                    query.append(WHERE_AND);
14721                            }
14722    
14723                            for (int i = 0; i < orderByConditionFields.length; i++) {
14724                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14725                                    query.append(orderByConditionFields[i]);
14726    
14727                                    if ((i + 1) < orderByConditionFields.length) {
14728                                            if (orderByComparator.isAscending() ^ previous) {
14729                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14730                                            }
14731                                            else {
14732                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14733                                            }
14734                                    }
14735                                    else {
14736                                            if (orderByComparator.isAscending() ^ previous) {
14737                                                    query.append(WHERE_GREATER_THAN);
14738                                            }
14739                                            else {
14740                                                    query.append(WHERE_LESSER_THAN);
14741                                            }
14742                                    }
14743                            }
14744    
14745                            query.append(ORDER_BY_CLAUSE);
14746    
14747                            String[] orderByFields = orderByComparator.getOrderByFields();
14748    
14749                            for (int i = 0; i < orderByFields.length; i++) {
14750                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14751                                    query.append(orderByFields[i]);
14752    
14753                                    if ((i + 1) < orderByFields.length) {
14754                                            if (orderByComparator.isAscending() ^ previous) {
14755                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14756                                            }
14757                                            else {
14758                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14759                                            }
14760                                    }
14761                                    else {
14762                                            if (orderByComparator.isAscending() ^ previous) {
14763                                                    query.append(ORDER_BY_ASC);
14764                                            }
14765                                            else {
14766                                                    query.append(ORDER_BY_DESC);
14767                                            }
14768                                    }
14769                            }
14770                    }
14771                    else {
14772                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14773                    }
14774    
14775                    String sql = query.toString();
14776    
14777                    Query q = session.createQuery(sql);
14778    
14779                    q.setFirstResult(0);
14780                    q.setMaxResults(2);
14781    
14782                    QueryPos qPos = QueryPos.getInstance(q);
14783    
14784                    qPos.add(companyId);
14785    
14786                    qPos.add(status);
14787    
14788                    if (orderByComparator != null) {
14789                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
14790    
14791                            for (Object value : values) {
14792                                    qPos.add(value);
14793                            }
14794                    }
14795    
14796                    List<JournalArticle> list = q.list();
14797    
14798                    if (list.size() == 2) {
14799                            return list.get(1);
14800                    }
14801                    else {
14802                            return null;
14803                    }
14804            }
14805    
14806            /**
14807             * Removes all the journal articles where companyId = &#63; and status = &#63; from the database.
14808             *
14809             * @param companyId the company ID
14810             * @param status the status
14811             * @throws SystemException if a system exception occurred
14812             */
14813            public void removeByC_ST(long companyId, int status)
14814                    throws SystemException {
14815                    for (JournalArticle journalArticle : findByC_ST(companyId, status,
14816                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14817                            remove(journalArticle);
14818                    }
14819            }
14820    
14821            /**
14822             * Returns the number of journal articles where companyId = &#63; and status = &#63;.
14823             *
14824             * @param companyId the company ID
14825             * @param status the status
14826             * @return the number of matching journal articles
14827             * @throws SystemException if a system exception occurred
14828             */
14829            public int countByC_ST(long companyId, int status)
14830                    throws SystemException {
14831                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_ST;
14832    
14833                    Object[] finderArgs = new Object[] { companyId, status };
14834    
14835                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
14836                                    this);
14837    
14838                    if (count == null) {
14839                            StringBundler query = new StringBundler(3);
14840    
14841                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14842    
14843                            query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
14844    
14845                            query.append(_FINDER_COLUMN_C_ST_STATUS_2);
14846    
14847                            String sql = query.toString();
14848    
14849                            Session session = null;
14850    
14851                            try {
14852                                    session = openSession();
14853    
14854                                    Query q = session.createQuery(sql);
14855    
14856                                    QueryPos qPos = QueryPos.getInstance(q);
14857    
14858                                    qPos.add(companyId);
14859    
14860                                    qPos.add(status);
14861    
14862                                    count = (Long)q.uniqueResult();
14863    
14864                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
14865                            }
14866                            catch (Exception e) {
14867                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14868    
14869                                    throw processException(e);
14870                            }
14871                            finally {
14872                                    closeSession(session);
14873                            }
14874                    }
14875    
14876                    return count.intValue();
14877            }
14878    
14879            private static final String _FINDER_COLUMN_C_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
14880            private static final String _FINDER_COLUMN_C_ST_STATUS_2 = "journalArticle.status = ?";
14881            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14882                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
14883                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
14884                            "findByG_F_ST",
14885                            new String[] {
14886                                    Long.class.getName(), Long.class.getName(),
14887                                    Integer.class.getName(),
14888                                    
14889                            Integer.class.getName(), Integer.class.getName(),
14890                                    OrderByComparator.class.getName()
14891                            });
14892            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST =
14893                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14894                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
14895                            JournalArticleImpl.class,
14896                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F_ST",
14897                            new String[] {
14898                                    Long.class.getName(), Long.class.getName(),
14899                                    Integer.class.getName()
14900                            },
14901                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
14902                            JournalArticleModelImpl.FOLDERID_COLUMN_BITMASK |
14903                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
14904                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
14905                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
14906            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14907                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
14908                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_ST",
14909                            new String[] {
14910                                    Long.class.getName(), Long.class.getName(),
14911                                    Integer.class.getName()
14912                            });
14913            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14914                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
14915                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F_ST",
14916                            new String[] {
14917                                    Long.class.getName(), Long.class.getName(),
14918                                    Integer.class.getName()
14919                            });
14920    
14921            /**
14922             * Returns all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
14923             *
14924             * @param groupId the group ID
14925             * @param folderId the folder ID
14926             * @param status the status
14927             * @return the matching journal articles
14928             * @throws SystemException if a system exception occurred
14929             */
14930            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
14931                    int status) throws SystemException {
14932                    return findByG_F_ST(groupId, folderId, status, QueryUtil.ALL_POS,
14933                            QueryUtil.ALL_POS, null);
14934            }
14935    
14936            /**
14937             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
14938             *
14939             * <p>
14940             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14941             * </p>
14942             *
14943             * @param groupId the group ID
14944             * @param folderId the folder ID
14945             * @param status the status
14946             * @param start the lower bound of the range of journal articles
14947             * @param end the upper bound of the range of journal articles (not inclusive)
14948             * @return the range of matching journal articles
14949             * @throws SystemException if a system exception occurred
14950             */
14951            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
14952                    int status, int start, int end) throws SystemException {
14953                    return findByG_F_ST(groupId, folderId, status, start, end, null);
14954            }
14955    
14956            /**
14957             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
14958             *
14959             * <p>
14960             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14961             * </p>
14962             *
14963             * @param groupId the group ID
14964             * @param folderId the folder ID
14965             * @param status the status
14966             * @param start the lower bound of the range of journal articles
14967             * @param end the upper bound of the range of journal articles (not inclusive)
14968             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14969             * @return the ordered range of matching journal articles
14970             * @throws SystemException if a system exception occurred
14971             */
14972            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
14973                    int status, int start, int end, OrderByComparator orderByComparator)
14974                    throws SystemException {
14975                    boolean pagination = true;
14976                    FinderPath finderPath = null;
14977                    Object[] finderArgs = null;
14978    
14979                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
14980                                    (orderByComparator == null)) {
14981                            pagination = false;
14982                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST;
14983                            finderArgs = new Object[] { groupId, folderId, status };
14984                    }
14985                    else {
14986                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST;
14987                            finderArgs = new Object[] {
14988                                            groupId, folderId, status,
14989                                            
14990                                            start, end, orderByComparator
14991                                    };
14992                    }
14993    
14994                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
14995                                    finderArgs, this);
14996    
14997                    if ((list != null) && !list.isEmpty()) {
14998                            for (JournalArticle journalArticle : list) {
14999                                    if ((groupId != journalArticle.getGroupId()) ||
15000                                                    (folderId != journalArticle.getFolderId()) ||
15001                                                    (status != journalArticle.getStatus())) {
15002                                            list = null;
15003    
15004                                            break;
15005                                    }
15006                            }
15007                    }
15008    
15009                    if (list == null) {
15010                            StringBundler query = null;
15011    
15012                            if (orderByComparator != null) {
15013                                    query = new StringBundler(5 +
15014                                                    (orderByComparator.getOrderByFields().length * 3));
15015                            }
15016                            else {
15017                                    query = new StringBundler(5);
15018                            }
15019    
15020                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15021    
15022                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
15023    
15024                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
15025    
15026                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
15027    
15028                            if (orderByComparator != null) {
15029                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15030                                            orderByComparator);
15031                            }
15032                            else
15033                             if (pagination) {
15034                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15035                            }
15036    
15037                            String sql = query.toString();
15038    
15039                            Session session = null;
15040    
15041                            try {
15042                                    session = openSession();
15043    
15044                                    Query q = session.createQuery(sql);
15045    
15046                                    QueryPos qPos = QueryPos.getInstance(q);
15047    
15048                                    qPos.add(groupId);
15049    
15050                                    qPos.add(folderId);
15051    
15052                                    qPos.add(status);
15053    
15054                                    if (!pagination) {
15055                                            list = (List<JournalArticle>)QueryUtil.list(q,
15056                                                            getDialect(), start, end, false);
15057    
15058                                            Collections.sort(list);
15059    
15060                                            list = new UnmodifiableList<JournalArticle>(list);
15061                                    }
15062                                    else {
15063                                            list = (List<JournalArticle>)QueryUtil.list(q,
15064                                                            getDialect(), start, end);
15065                                    }
15066    
15067                                    cacheResult(list);
15068    
15069                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
15070                            }
15071                            catch (Exception e) {
15072                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15073    
15074                                    throw processException(e);
15075                            }
15076                            finally {
15077                                    closeSession(session);
15078                            }
15079                    }
15080    
15081                    return list;
15082            }
15083    
15084            /**
15085             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
15086             *
15087             * @param groupId the group ID
15088             * @param folderId the folder ID
15089             * @param status the status
15090             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15091             * @return the first matching journal article
15092             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15093             * @throws SystemException if a system exception occurred
15094             */
15095            public JournalArticle findByG_F_ST_First(long groupId, long folderId,
15096                    int status, OrderByComparator orderByComparator)
15097                    throws NoSuchArticleException, SystemException {
15098                    JournalArticle journalArticle = fetchByG_F_ST_First(groupId, folderId,
15099                                    status, orderByComparator);
15100    
15101                    if (journalArticle != null) {
15102                            return journalArticle;
15103                    }
15104    
15105                    StringBundler msg = new StringBundler(8);
15106    
15107                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15108    
15109                    msg.append("groupId=");
15110                    msg.append(groupId);
15111    
15112                    msg.append(", folderId=");
15113                    msg.append(folderId);
15114    
15115                    msg.append(", status=");
15116                    msg.append(status);
15117    
15118                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15119    
15120                    throw new NoSuchArticleException(msg.toString());
15121            }
15122    
15123            /**
15124             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
15125             *
15126             * @param groupId the group ID
15127             * @param folderId the folder ID
15128             * @param status the status
15129             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15130             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
15131             * @throws SystemException if a system exception occurred
15132             */
15133            public JournalArticle fetchByG_F_ST_First(long groupId, long folderId,
15134                    int status, OrderByComparator orderByComparator)
15135                    throws SystemException {
15136                    List<JournalArticle> list = findByG_F_ST(groupId, folderId, status, 0,
15137                                    1, orderByComparator);
15138    
15139                    if (!list.isEmpty()) {
15140                            return list.get(0);
15141                    }
15142    
15143                    return null;
15144            }
15145    
15146            /**
15147             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
15148             *
15149             * @param groupId the group ID
15150             * @param folderId the folder ID
15151             * @param status the status
15152             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15153             * @return the last matching journal article
15154             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15155             * @throws SystemException if a system exception occurred
15156             */
15157            public JournalArticle findByG_F_ST_Last(long groupId, long folderId,
15158                    int status, OrderByComparator orderByComparator)
15159                    throws NoSuchArticleException, SystemException {
15160                    JournalArticle journalArticle = fetchByG_F_ST_Last(groupId, folderId,
15161                                    status, orderByComparator);
15162    
15163                    if (journalArticle != null) {
15164                            return journalArticle;
15165                    }
15166    
15167                    StringBundler msg = new StringBundler(8);
15168    
15169                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15170    
15171                    msg.append("groupId=");
15172                    msg.append(groupId);
15173    
15174                    msg.append(", folderId=");
15175                    msg.append(folderId);
15176    
15177                    msg.append(", status=");
15178                    msg.append(status);
15179    
15180                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15181    
15182                    throw new NoSuchArticleException(msg.toString());
15183            }
15184    
15185            /**
15186             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
15187             *
15188             * @param groupId the group ID
15189             * @param folderId the folder ID
15190             * @param status the status
15191             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15192             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
15193             * @throws SystemException if a system exception occurred
15194             */
15195            public JournalArticle fetchByG_F_ST_Last(long groupId, long folderId,
15196                    int status, OrderByComparator orderByComparator)
15197                    throws SystemException {
15198                    int count = countByG_F_ST(groupId, folderId, status);
15199    
15200                    List<JournalArticle> list = findByG_F_ST(groupId, folderId, status,
15201                                    count - 1, count, orderByComparator);
15202    
15203                    if (!list.isEmpty()) {
15204                            return list.get(0);
15205                    }
15206    
15207                    return null;
15208            }
15209    
15210            /**
15211             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
15212             *
15213             * @param id the primary key of the current journal article
15214             * @param groupId the group ID
15215             * @param folderId the folder ID
15216             * @param status the status
15217             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15218             * @return the previous, current, and next journal article
15219             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
15220             * @throws SystemException if a system exception occurred
15221             */
15222            public JournalArticle[] findByG_F_ST_PrevAndNext(long id, long groupId,
15223                    long folderId, int status, OrderByComparator orderByComparator)
15224                    throws NoSuchArticleException, SystemException {
15225                    JournalArticle journalArticle = findByPrimaryKey(id);
15226    
15227                    Session session = null;
15228    
15229                    try {
15230                            session = openSession();
15231    
15232                            JournalArticle[] array = new JournalArticleImpl[3];
15233    
15234                            array[0] = getByG_F_ST_PrevAndNext(session, journalArticle,
15235                                            groupId, folderId, status, orderByComparator, true);
15236    
15237                            array[1] = journalArticle;
15238    
15239                            array[2] = getByG_F_ST_PrevAndNext(session, journalArticle,
15240                                            groupId, folderId, status, orderByComparator, false);
15241    
15242                            return array;
15243                    }
15244                    catch (Exception e) {
15245                            throw processException(e);
15246                    }
15247                    finally {
15248                            closeSession(session);
15249                    }
15250            }
15251    
15252            protected JournalArticle getByG_F_ST_PrevAndNext(Session session,
15253                    JournalArticle journalArticle, long groupId, long folderId, int status,
15254                    OrderByComparator orderByComparator, boolean previous) {
15255                    StringBundler query = null;
15256    
15257                    if (orderByComparator != null) {
15258                            query = new StringBundler(6 +
15259                                            (orderByComparator.getOrderByFields().length * 6));
15260                    }
15261                    else {
15262                            query = new StringBundler(3);
15263                    }
15264    
15265                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15266    
15267                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
15268    
15269                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
15270    
15271                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
15272    
15273                    if (orderByComparator != null) {
15274                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15275    
15276                            if (orderByConditionFields.length > 0) {
15277                                    query.append(WHERE_AND);
15278                            }
15279    
15280                            for (int i = 0; i < orderByConditionFields.length; i++) {
15281                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15282                                    query.append(orderByConditionFields[i]);
15283    
15284                                    if ((i + 1) < orderByConditionFields.length) {
15285                                            if (orderByComparator.isAscending() ^ previous) {
15286                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15287                                            }
15288                                            else {
15289                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15290                                            }
15291                                    }
15292                                    else {
15293                                            if (orderByComparator.isAscending() ^ previous) {
15294                                                    query.append(WHERE_GREATER_THAN);
15295                                            }
15296                                            else {
15297                                                    query.append(WHERE_LESSER_THAN);
15298                                            }
15299                                    }
15300                            }
15301    
15302                            query.append(ORDER_BY_CLAUSE);
15303    
15304                            String[] orderByFields = orderByComparator.getOrderByFields();
15305    
15306                            for (int i = 0; i < orderByFields.length; i++) {
15307                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15308                                    query.append(orderByFields[i]);
15309    
15310                                    if ((i + 1) < orderByFields.length) {
15311                                            if (orderByComparator.isAscending() ^ previous) {
15312                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15313                                            }
15314                                            else {
15315                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15316                                            }
15317                                    }
15318                                    else {
15319                                            if (orderByComparator.isAscending() ^ previous) {
15320                                                    query.append(ORDER_BY_ASC);
15321                                            }
15322                                            else {
15323                                                    query.append(ORDER_BY_DESC);
15324                                            }
15325                                    }
15326                            }
15327                    }
15328                    else {
15329                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15330                    }
15331    
15332                    String sql = query.toString();
15333    
15334                    Query q = session.createQuery(sql);
15335    
15336                    q.setFirstResult(0);
15337                    q.setMaxResults(2);
15338    
15339                    QueryPos qPos = QueryPos.getInstance(q);
15340    
15341                    qPos.add(groupId);
15342    
15343                    qPos.add(folderId);
15344    
15345                    qPos.add(status);
15346    
15347                    if (orderByComparator != null) {
15348                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
15349    
15350                            for (Object value : values) {
15351                                    qPos.add(value);
15352                            }
15353                    }
15354    
15355                    List<JournalArticle> list = q.list();
15356    
15357                    if (list.size() == 2) {
15358                            return list.get(1);
15359                    }
15360                    else {
15361                            return null;
15362                    }
15363            }
15364    
15365            /**
15366             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
15367             *
15368             * @param groupId the group ID
15369             * @param folderId the folder ID
15370             * @param status the status
15371             * @return the matching journal articles that the user has permission to view
15372             * @throws SystemException if a system exception occurred
15373             */
15374            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
15375                    int status) throws SystemException {
15376                    return filterFindByG_F_ST(groupId, folderId, status, QueryUtil.ALL_POS,
15377                            QueryUtil.ALL_POS, null);
15378            }
15379    
15380            /**
15381             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
15382             *
15383             * <p>
15384             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15385             * </p>
15386             *
15387             * @param groupId the group ID
15388             * @param folderId the folder ID
15389             * @param status the status
15390             * @param start the lower bound of the range of journal articles
15391             * @param end the upper bound of the range of journal articles (not inclusive)
15392             * @return the range of matching journal articles that the user has permission to view
15393             * @throws SystemException if a system exception occurred
15394             */
15395            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
15396                    int status, int start, int end) throws SystemException {
15397                    return filterFindByG_F_ST(groupId, folderId, status, start, end, null);
15398            }
15399    
15400            /**
15401             * 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;.
15402             *
15403             * <p>
15404             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15405             * </p>
15406             *
15407             * @param groupId the group ID
15408             * @param folderId the folder ID
15409             * @param status the status
15410             * @param start the lower bound of the range of journal articles
15411             * @param end the upper bound of the range of journal articles (not inclusive)
15412             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15413             * @return the ordered range of matching journal articles that the user has permission to view
15414             * @throws SystemException if a system exception occurred
15415             */
15416            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
15417                    int status, int start, int end, OrderByComparator orderByComparator)
15418                    throws SystemException {
15419                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15420                            return findByG_F_ST(groupId, folderId, status, start, end,
15421                                    orderByComparator);
15422                    }
15423    
15424                    StringBundler query = null;
15425    
15426                    if (orderByComparator != null) {
15427                            query = new StringBundler(5 +
15428                                            (orderByComparator.getOrderByFields().length * 3));
15429                    }
15430                    else {
15431                            query = new StringBundler(5);
15432                    }
15433    
15434                    if (getDB().isSupportsInlineDistinct()) {
15435                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
15436                    }
15437                    else {
15438                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
15439                    }
15440    
15441                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
15442    
15443                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
15444    
15445                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
15446    
15447                    if (!getDB().isSupportsInlineDistinct()) {
15448                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
15449                    }
15450    
15451                    if (orderByComparator != null) {
15452                            if (getDB().isSupportsInlineDistinct()) {
15453                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15454                                            orderByComparator);
15455                            }
15456                            else {
15457                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
15458                                            orderByComparator);
15459                            }
15460                    }
15461                    else {
15462                            if (getDB().isSupportsInlineDistinct()) {
15463                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15464                            }
15465                            else {
15466                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
15467                            }
15468                    }
15469    
15470                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15471                                    JournalArticle.class.getName(),
15472                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15473    
15474                    Session session = null;
15475    
15476                    try {
15477                            session = openSession();
15478    
15479                            SQLQuery q = session.createSQLQuery(sql);
15480    
15481                            if (getDB().isSupportsInlineDistinct()) {
15482                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
15483                            }
15484                            else {
15485                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
15486                            }
15487    
15488                            QueryPos qPos = QueryPos.getInstance(q);
15489    
15490                            qPos.add(groupId);
15491    
15492                            qPos.add(folderId);
15493    
15494                            qPos.add(status);
15495    
15496                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
15497                                    end);
15498                    }
15499                    catch (Exception e) {
15500                            throw processException(e);
15501                    }
15502                    finally {
15503                            closeSession(session);
15504                    }
15505            }
15506    
15507            /**
15508             * 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;.
15509             *
15510             * @param id the primary key of the current journal article
15511             * @param groupId the group ID
15512             * @param folderId the folder ID
15513             * @param status the status
15514             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15515             * @return the previous, current, and next journal article
15516             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
15517             * @throws SystemException if a system exception occurred
15518             */
15519            public JournalArticle[] filterFindByG_F_ST_PrevAndNext(long id,
15520                    long groupId, long folderId, int status,
15521                    OrderByComparator orderByComparator)
15522                    throws NoSuchArticleException, SystemException {
15523                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15524                            return findByG_F_ST_PrevAndNext(id, groupId, folderId, status,
15525                                    orderByComparator);
15526                    }
15527    
15528                    JournalArticle journalArticle = findByPrimaryKey(id);
15529    
15530                    Session session = null;
15531    
15532                    try {
15533                            session = openSession();
15534    
15535                            JournalArticle[] array = new JournalArticleImpl[3];
15536    
15537                            array[0] = filterGetByG_F_ST_PrevAndNext(session, journalArticle,
15538                                            groupId, folderId, status, orderByComparator, true);
15539    
15540                            array[1] = journalArticle;
15541    
15542                            array[2] = filterGetByG_F_ST_PrevAndNext(session, journalArticle,
15543                                            groupId, folderId, status, orderByComparator, false);
15544    
15545                            return array;
15546                    }
15547                    catch (Exception e) {
15548                            throw processException(e);
15549                    }
15550                    finally {
15551                            closeSession(session);
15552                    }
15553            }
15554    
15555            protected JournalArticle filterGetByG_F_ST_PrevAndNext(Session session,
15556                    JournalArticle journalArticle, long groupId, long folderId, int status,
15557                    OrderByComparator orderByComparator, boolean previous) {
15558                    StringBundler query = null;
15559    
15560                    if (orderByComparator != null) {
15561                            query = new StringBundler(6 +
15562                                            (orderByComparator.getOrderByFields().length * 6));
15563                    }
15564                    else {
15565                            query = new StringBundler(3);
15566                    }
15567    
15568                    if (getDB().isSupportsInlineDistinct()) {
15569                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
15570                    }
15571                    else {
15572                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
15573                    }
15574    
15575                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
15576    
15577                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
15578    
15579                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
15580    
15581                    if (!getDB().isSupportsInlineDistinct()) {
15582                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
15583                    }
15584    
15585                    if (orderByComparator != null) {
15586                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15587    
15588                            if (orderByConditionFields.length > 0) {
15589                                    query.append(WHERE_AND);
15590                            }
15591    
15592                            for (int i = 0; i < orderByConditionFields.length; i++) {
15593                                    if (getDB().isSupportsInlineDistinct()) {
15594                                            query.append(_ORDER_BY_ENTITY_ALIAS);
15595                                    }
15596                                    else {
15597                                            query.append(_ORDER_BY_ENTITY_TABLE);
15598                                    }
15599    
15600                                    query.append(orderByConditionFields[i]);
15601    
15602                                    if ((i + 1) < orderByConditionFields.length) {
15603                                            if (orderByComparator.isAscending() ^ previous) {
15604                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15605                                            }
15606                                            else {
15607                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15608                                            }
15609                                    }
15610                                    else {
15611                                            if (orderByComparator.isAscending() ^ previous) {
15612                                                    query.append(WHERE_GREATER_THAN);
15613                                            }
15614                                            else {
15615                                                    query.append(WHERE_LESSER_THAN);
15616                                            }
15617                                    }
15618                            }
15619    
15620                            query.append(ORDER_BY_CLAUSE);
15621    
15622                            String[] orderByFields = orderByComparator.getOrderByFields();
15623    
15624                            for (int i = 0; i < orderByFields.length; i++) {
15625                                    if (getDB().isSupportsInlineDistinct()) {
15626                                            query.append(_ORDER_BY_ENTITY_ALIAS);
15627                                    }
15628                                    else {
15629                                            query.append(_ORDER_BY_ENTITY_TABLE);
15630                                    }
15631    
15632                                    query.append(orderByFields[i]);
15633    
15634                                    if ((i + 1) < orderByFields.length) {
15635                                            if (orderByComparator.isAscending() ^ previous) {
15636                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15637                                            }
15638                                            else {
15639                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15640                                            }
15641                                    }
15642                                    else {
15643                                            if (orderByComparator.isAscending() ^ previous) {
15644                                                    query.append(ORDER_BY_ASC);
15645                                            }
15646                                            else {
15647                                                    query.append(ORDER_BY_DESC);
15648                                            }
15649                                    }
15650                            }
15651                    }
15652                    else {
15653                            if (getDB().isSupportsInlineDistinct()) {
15654                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15655                            }
15656                            else {
15657                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
15658                            }
15659                    }
15660    
15661                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15662                                    JournalArticle.class.getName(),
15663                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15664    
15665                    SQLQuery q = session.createSQLQuery(sql);
15666    
15667                    q.setFirstResult(0);
15668                    q.setMaxResults(2);
15669    
15670                    if (getDB().isSupportsInlineDistinct()) {
15671                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
15672                    }
15673                    else {
15674                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
15675                    }
15676    
15677                    QueryPos qPos = QueryPos.getInstance(q);
15678    
15679                    qPos.add(groupId);
15680    
15681                    qPos.add(folderId);
15682    
15683                    qPos.add(status);
15684    
15685                    if (orderByComparator != null) {
15686                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
15687    
15688                            for (Object value : values) {
15689                                    qPos.add(value);
15690                            }
15691                    }
15692    
15693                    List<JournalArticle> list = q.list();
15694    
15695                    if (list.size() == 2) {
15696                            return list.get(1);
15697                    }
15698                    else {
15699                            return null;
15700                    }
15701            }
15702    
15703            /**
15704             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = any &#63;.
15705             *
15706             * @param groupId the group ID
15707             * @param folderId the folder ID
15708             * @param statuses the statuses
15709             * @return the matching journal articles that the user has permission to view
15710             * @throws SystemException if a system exception occurred
15711             */
15712            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
15713                    int[] statuses) throws SystemException {
15714                    return filterFindByG_F_ST(groupId, folderId, statuses,
15715                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
15716            }
15717    
15718            /**
15719             * 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;.
15720             *
15721             * <p>
15722             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15723             * </p>
15724             *
15725             * @param groupId the group ID
15726             * @param folderId the folder ID
15727             * @param statuses the statuses
15728             * @param start the lower bound of the range of journal articles
15729             * @param end the upper bound of the range of journal articles (not inclusive)
15730             * @return the range of matching journal articles that the user has permission to view
15731             * @throws SystemException if a system exception occurred
15732             */
15733            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
15734                    int[] statuses, int start, int end) throws SystemException {
15735                    return filterFindByG_F_ST(groupId, folderId, statuses, start, end, null);
15736            }
15737    
15738            /**
15739             * 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;.
15740             *
15741             * <p>
15742             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15743             * </p>
15744             *
15745             * @param groupId the group ID
15746             * @param folderId the folder ID
15747             * @param statuses the statuses
15748             * @param start the lower bound of the range of journal articles
15749             * @param end the upper bound of the range of journal articles (not inclusive)
15750             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15751             * @return the ordered range of matching journal articles that the user has permission to view
15752             * @throws SystemException if a system exception occurred
15753             */
15754            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
15755                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
15756                    throws SystemException {
15757                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15758                            return findByG_F_ST(groupId, folderId, statuses, start, end,
15759                                    orderByComparator);
15760                    }
15761    
15762                    StringBundler query = new StringBundler();
15763    
15764                    if (getDB().isSupportsInlineDistinct()) {
15765                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
15766                    }
15767                    else {
15768                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
15769                    }
15770    
15771                    boolean conjunctionable = false;
15772    
15773                    if (conjunctionable) {
15774                            query.append(WHERE_AND);
15775                    }
15776    
15777                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
15778    
15779                    conjunctionable = true;
15780    
15781                    if (conjunctionable) {
15782                            query.append(WHERE_AND);
15783                    }
15784    
15785                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
15786    
15787                    conjunctionable = true;
15788    
15789                    if ((statuses == null) || (statuses.length > 0)) {
15790                            if (conjunctionable) {
15791                                    query.append(WHERE_AND);
15792                            }
15793    
15794                            query.append(StringPool.OPEN_PARENTHESIS);
15795    
15796                            for (int i = 0; i < statuses.length; i++) {
15797                                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
15798    
15799                                    if ((i + 1) < statuses.length) {
15800                                            query.append(WHERE_OR);
15801                                    }
15802                            }
15803    
15804                            query.append(StringPool.CLOSE_PARENTHESIS);
15805    
15806                            conjunctionable = true;
15807                    }
15808    
15809                    if (!getDB().isSupportsInlineDistinct()) {
15810                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
15811                    }
15812    
15813                    if (orderByComparator != null) {
15814                            if (getDB().isSupportsInlineDistinct()) {
15815                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15816                                            orderByComparator);
15817                            }
15818                            else {
15819                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
15820                                            orderByComparator);
15821                            }
15822                    }
15823                    else {
15824                            if (getDB().isSupportsInlineDistinct()) {
15825                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15826                            }
15827                            else {
15828                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
15829                            }
15830                    }
15831    
15832                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15833                                    JournalArticle.class.getName(),
15834                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15835    
15836                    Session session = null;
15837    
15838                    try {
15839                            session = openSession();
15840    
15841                            SQLQuery q = session.createSQLQuery(sql);
15842    
15843                            if (getDB().isSupportsInlineDistinct()) {
15844                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
15845                            }
15846                            else {
15847                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
15848                            }
15849    
15850                            QueryPos qPos = QueryPos.getInstance(q);
15851    
15852                            qPos.add(groupId);
15853    
15854                            qPos.add(folderId);
15855    
15856                            if (statuses != null) {
15857                                    qPos.add(statuses);
15858                            }
15859    
15860                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
15861                                    end);
15862                    }
15863                    catch (Exception e) {
15864                            throw processException(e);
15865                    }
15866                    finally {
15867                            closeSession(session);
15868                    }
15869            }
15870    
15871            /**
15872             * Returns all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
15873             *
15874             * <p>
15875             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15876             * </p>
15877             *
15878             * @param groupId the group ID
15879             * @param folderId the folder ID
15880             * @param statuses the statuses
15881             * @return the matching journal articles
15882             * @throws SystemException if a system exception occurred
15883             */
15884            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
15885                    int[] statuses) throws SystemException {
15886                    return findByG_F_ST(groupId, folderId, statuses, QueryUtil.ALL_POS,
15887                            QueryUtil.ALL_POS, null);
15888            }
15889    
15890            /**
15891             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
15892             *
15893             * <p>
15894             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15895             * </p>
15896             *
15897             * @param groupId the group ID
15898             * @param folderId the folder ID
15899             * @param statuses the statuses
15900             * @param start the lower bound of the range of journal articles
15901             * @param end the upper bound of the range of journal articles (not inclusive)
15902             * @return the range of matching journal articles
15903             * @throws SystemException if a system exception occurred
15904             */
15905            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
15906                    int[] statuses, int start, int end) throws SystemException {
15907                    return findByG_F_ST(groupId, folderId, statuses, start, end, null);
15908            }
15909    
15910            /**
15911             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
15912             *
15913             * <p>
15914             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15915             * </p>
15916             *
15917             * @param groupId the group ID
15918             * @param folderId the folder ID
15919             * @param statuses the statuses
15920             * @param start the lower bound of the range of journal articles
15921             * @param end the upper bound of the range of journal articles (not inclusive)
15922             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15923             * @return the ordered range of matching journal articles
15924             * @throws SystemException if a system exception occurred
15925             */
15926            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
15927                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
15928                    throws SystemException {
15929                    if ((statuses != null) && (statuses.length == 1)) {
15930                            return findByG_F_ST(groupId, folderId, statuses[0], start, end,
15931                                    orderByComparator);
15932                    }
15933    
15934                    boolean pagination = true;
15935                    Object[] finderArgs = null;
15936    
15937                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
15938                                    (orderByComparator == null)) {
15939                            pagination = false;
15940                            finderArgs = new Object[] {
15941                                            groupId, folderId, StringUtil.merge(statuses)
15942                                    };
15943                    }
15944                    else {
15945                            finderArgs = new Object[] {
15946                                            groupId, folderId, StringUtil.merge(statuses),
15947                                            
15948                                            start, end, orderByComparator
15949                                    };
15950                    }
15951    
15952                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
15953                                    finderArgs, this);
15954    
15955                    if ((list != null) && !list.isEmpty()) {
15956                            for (JournalArticle journalArticle : list) {
15957                                    if ((groupId != journalArticle.getGroupId()) ||
15958                                                    (folderId != journalArticle.getFolderId()) ||
15959                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
15960                                            list = null;
15961    
15962                                            break;
15963                                    }
15964                            }
15965                    }
15966    
15967                    if (list == null) {
15968                            StringBundler query = new StringBundler();
15969    
15970                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15971    
15972                            boolean conjunctionable = false;
15973    
15974                            if (conjunctionable) {
15975                                    query.append(WHERE_AND);
15976                            }
15977    
15978                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
15979    
15980                            conjunctionable = true;
15981    
15982                            if (conjunctionable) {
15983                                    query.append(WHERE_AND);
15984                            }
15985    
15986                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
15987    
15988                            conjunctionable = true;
15989    
15990                            if ((statuses == null) || (statuses.length > 0)) {
15991                                    if (conjunctionable) {
15992                                            query.append(WHERE_AND);
15993                                    }
15994    
15995                                    query.append(StringPool.OPEN_PARENTHESIS);
15996    
15997                                    for (int i = 0; i < statuses.length; i++) {
15998                                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
15999    
16000                                            if ((i + 1) < statuses.length) {
16001                                                    query.append(WHERE_OR);
16002                                            }
16003                                    }
16004    
16005                                    query.append(StringPool.CLOSE_PARENTHESIS);
16006    
16007                                    conjunctionable = true;
16008                            }
16009    
16010                            if (orderByComparator != null) {
16011                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16012                                            orderByComparator);
16013                            }
16014                            else
16015                             if (pagination) {
16016                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16017                            }
16018    
16019                            String sql = query.toString();
16020    
16021                            Session session = null;
16022    
16023                            try {
16024                                    session = openSession();
16025    
16026                                    Query q = session.createQuery(sql);
16027    
16028                                    QueryPos qPos = QueryPos.getInstance(q);
16029    
16030                                    qPos.add(groupId);
16031    
16032                                    qPos.add(folderId);
16033    
16034                                    if (statuses != null) {
16035                                            qPos.add(statuses);
16036                                    }
16037    
16038                                    if (!pagination) {
16039                                            list = (List<JournalArticle>)QueryUtil.list(q,
16040                                                            getDialect(), start, end, false);
16041    
16042                                            Collections.sort(list);
16043    
16044                                            list = new UnmodifiableList<JournalArticle>(list);
16045                                    }
16046                                    else {
16047                                            list = (List<JournalArticle>)QueryUtil.list(q,
16048                                                            getDialect(), start, end);
16049                                    }
16050    
16051                                    cacheResult(list);
16052    
16053                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
16054                                            finderArgs, list);
16055                            }
16056                            catch (Exception e) {
16057                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
16058                                            finderArgs);
16059    
16060                                    throw processException(e);
16061                            }
16062                            finally {
16063                                    closeSession(session);
16064                            }
16065                    }
16066    
16067                    return list;
16068            }
16069    
16070            /**
16071             * Removes all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63; from the database.
16072             *
16073             * @param groupId the group ID
16074             * @param folderId the folder ID
16075             * @param status the status
16076             * @throws SystemException if a system exception occurred
16077             */
16078            public void removeByG_F_ST(long groupId, long folderId, int status)
16079                    throws SystemException {
16080                    for (JournalArticle journalArticle : findByG_F_ST(groupId, folderId,
16081                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
16082                            remove(journalArticle);
16083                    }
16084            }
16085    
16086            /**
16087             * Returns the number of journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
16088             *
16089             * @param groupId the group ID
16090             * @param folderId the folder ID
16091             * @param status the status
16092             * @return the number of matching journal articles
16093             * @throws SystemException if a system exception occurred
16094             */
16095            public int countByG_F_ST(long groupId, long folderId, int status)
16096                    throws SystemException {
16097                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F_ST;
16098    
16099                    Object[] finderArgs = new Object[] { groupId, folderId, status };
16100    
16101                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
16102                                    this);
16103    
16104                    if (count == null) {
16105                            StringBundler query = new StringBundler(4);
16106    
16107                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16108    
16109                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
16110    
16111                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
16112    
16113                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
16114    
16115                            String sql = query.toString();
16116    
16117                            Session session = null;
16118    
16119                            try {
16120                                    session = openSession();
16121    
16122                                    Query q = session.createQuery(sql);
16123    
16124                                    QueryPos qPos = QueryPos.getInstance(q);
16125    
16126                                    qPos.add(groupId);
16127    
16128                                    qPos.add(folderId);
16129    
16130                                    qPos.add(status);
16131    
16132                                    count = (Long)q.uniqueResult();
16133    
16134                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
16135                            }
16136                            catch (Exception e) {
16137                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16138    
16139                                    throw processException(e);
16140                            }
16141                            finally {
16142                                    closeSession(session);
16143                            }
16144                    }
16145    
16146                    return count.intValue();
16147            }
16148    
16149            /**
16150             * Returns the number of journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
16151             *
16152             * @param groupId the group ID
16153             * @param folderId the folder ID
16154             * @param statuses the statuses
16155             * @return the number of matching journal articles
16156             * @throws SystemException if a system exception occurred
16157             */
16158            public int countByG_F_ST(long groupId, long folderId, int[] statuses)
16159                    throws SystemException {
16160                    Object[] finderArgs = new Object[] {
16161                                    groupId, folderId, StringUtil.merge(statuses)
16162                            };
16163    
16164                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
16165                                    finderArgs, this);
16166    
16167                    if (count == null) {
16168                            StringBundler query = new StringBundler();
16169    
16170                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16171    
16172                            boolean conjunctionable = false;
16173    
16174                            if (conjunctionable) {
16175                                    query.append(WHERE_AND);
16176                            }
16177    
16178                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
16179    
16180                            conjunctionable = true;
16181    
16182                            if (conjunctionable) {
16183                                    query.append(WHERE_AND);
16184                            }
16185    
16186                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
16187    
16188                            conjunctionable = true;
16189    
16190                            if ((statuses == null) || (statuses.length > 0)) {
16191                                    if (conjunctionable) {
16192                                            query.append(WHERE_AND);
16193                                    }
16194    
16195                                    query.append(StringPool.OPEN_PARENTHESIS);
16196    
16197                                    for (int i = 0; i < statuses.length; i++) {
16198                                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
16199    
16200                                            if ((i + 1) < statuses.length) {
16201                                                    query.append(WHERE_OR);
16202                                            }
16203                                    }
16204    
16205                                    query.append(StringPool.CLOSE_PARENTHESIS);
16206    
16207                                    conjunctionable = true;
16208                            }
16209    
16210                            String sql = query.toString();
16211    
16212                            Session session = null;
16213    
16214                            try {
16215                                    session = openSession();
16216    
16217                                    Query q = session.createQuery(sql);
16218    
16219                                    QueryPos qPos = QueryPos.getInstance(q);
16220    
16221                                    qPos.add(groupId);
16222    
16223                                    qPos.add(folderId);
16224    
16225                                    if (statuses != null) {
16226                                            qPos.add(statuses);
16227                                    }
16228    
16229                                    count = (Long)q.uniqueResult();
16230    
16231                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
16232                                            finderArgs, count);
16233                            }
16234                            catch (Exception e) {
16235                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
16236                                            finderArgs);
16237    
16238                                    throw processException(e);
16239                            }
16240                            finally {
16241                                    closeSession(session);
16242                            }
16243                    }
16244    
16245                    return count.intValue();
16246            }
16247    
16248            /**
16249             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
16250             *
16251             * @param groupId the group ID
16252             * @param folderId the folder ID
16253             * @param status the status
16254             * @return the number of matching journal articles that the user has permission to view
16255             * @throws SystemException if a system exception occurred
16256             */
16257            public int filterCountByG_F_ST(long groupId, long folderId, int status)
16258                    throws SystemException {
16259                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16260                            return countByG_F_ST(groupId, folderId, status);
16261                    }
16262    
16263                    StringBundler query = new StringBundler(4);
16264    
16265                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
16266    
16267                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
16268    
16269                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
16270    
16271                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
16272    
16273                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16274                                    JournalArticle.class.getName(),
16275                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16276    
16277                    Session session = null;
16278    
16279                    try {
16280                            session = openSession();
16281    
16282                            SQLQuery q = session.createSQLQuery(sql);
16283    
16284                            q.addScalar(COUNT_COLUMN_NAME,
16285                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16286    
16287                            QueryPos qPos = QueryPos.getInstance(q);
16288    
16289                            qPos.add(groupId);
16290    
16291                            qPos.add(folderId);
16292    
16293                            qPos.add(status);
16294    
16295                            Long count = (Long)q.uniqueResult();
16296    
16297                            return count.intValue();
16298                    }
16299                    catch (Exception e) {
16300                            throw processException(e);
16301                    }
16302                    finally {
16303                            closeSession(session);
16304                    }
16305            }
16306    
16307            /**
16308             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = any &#63;.
16309             *
16310             * @param groupId the group ID
16311             * @param folderId the folder ID
16312             * @param statuses the statuses
16313             * @return the number of matching journal articles that the user has permission to view
16314             * @throws SystemException if a system exception occurred
16315             */
16316            public int filterCountByG_F_ST(long groupId, long folderId, int[] statuses)
16317                    throws SystemException {
16318                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16319                            return countByG_F_ST(groupId, folderId, statuses);
16320                    }
16321    
16322                    StringBundler query = new StringBundler();
16323    
16324                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
16325    
16326                    boolean conjunctionable = false;
16327    
16328                    if (conjunctionable) {
16329                            query.append(WHERE_AND);
16330                    }
16331    
16332                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
16333    
16334                    conjunctionable = true;
16335    
16336                    if (conjunctionable) {
16337                            query.append(WHERE_AND);
16338                    }
16339    
16340                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
16341    
16342                    conjunctionable = true;
16343    
16344                    if ((statuses == null) || (statuses.length > 0)) {
16345                            if (conjunctionable) {
16346                                    query.append(WHERE_AND);
16347                            }
16348    
16349                            query.append(StringPool.OPEN_PARENTHESIS);
16350    
16351                            for (int i = 0; i < statuses.length; i++) {
16352                                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
16353    
16354                                    if ((i + 1) < statuses.length) {
16355                                            query.append(WHERE_OR);
16356                                    }
16357                            }
16358    
16359                            query.append(StringPool.CLOSE_PARENTHESIS);
16360    
16361                            conjunctionable = true;
16362                    }
16363    
16364                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16365                                    JournalArticle.class.getName(),
16366                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16367    
16368                    Session session = null;
16369    
16370                    try {
16371                            session = openSession();
16372    
16373                            SQLQuery q = session.createSQLQuery(sql);
16374    
16375                            q.addScalar(COUNT_COLUMN_NAME,
16376                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16377    
16378                            QueryPos qPos = QueryPos.getInstance(q);
16379    
16380                            qPos.add(groupId);
16381    
16382                            qPos.add(folderId);
16383    
16384                            if (statuses != null) {
16385                                    qPos.add(statuses);
16386                            }
16387    
16388                            Long count = (Long)q.uniqueResult();
16389    
16390                            return count.intValue();
16391                    }
16392                    catch (Exception e) {
16393                            throw processException(e);
16394                    }
16395                    finally {
16396                            closeSession(session);
16397                    }
16398            }
16399    
16400            private static final String _FINDER_COLUMN_G_F_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
16401            private static final String _FINDER_COLUMN_G_F_ST_GROUPID_5 = "(" +
16402                    _removeConjunction(_FINDER_COLUMN_G_F_ST_GROUPID_2) + ")";
16403            private static final String _FINDER_COLUMN_G_F_ST_FOLDERID_2 = "journalArticle.folderId = ? AND ";
16404            private static final String _FINDER_COLUMN_G_F_ST_FOLDERID_5 = "(" +
16405                    _removeConjunction(_FINDER_COLUMN_G_F_ST_FOLDERID_2) + ")";
16406            private static final String _FINDER_COLUMN_G_F_ST_STATUS_2 = "journalArticle.status = ?";
16407            private static final String _FINDER_COLUMN_G_F_ST_STATUS_5 = "(" +
16408                    _removeConjunction(_FINDER_COLUMN_G_F_ST_STATUS_2) + ")";
16409            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16410                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
16411                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
16412                            "findByG_C_C",
16413                            new String[] {
16414                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
16415                                    
16416                            Integer.class.getName(), Integer.class.getName(),
16417                                    OrderByComparator.class.getName()
16418                            });
16419            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16420                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
16421                            JournalArticleImpl.class,
16422                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_C",
16423                            new String[] {
16424                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
16425                            },
16426                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
16427                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
16428                            JournalArticleModelImpl.CLASSPK_COLUMN_BITMASK |
16429                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
16430                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
16431            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16432                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
16433                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_C",
16434                            new String[] {
16435                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
16436                            });
16437    
16438            /**
16439             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
16440             *
16441             * @param groupId the group ID
16442             * @param classNameId the class name ID
16443             * @param classPK the class p k
16444             * @return the matching journal articles
16445             * @throws SystemException if a system exception occurred
16446             */
16447            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
16448                    long classPK) throws SystemException {
16449                    return findByG_C_C(groupId, classNameId, classPK, QueryUtil.ALL_POS,
16450                            QueryUtil.ALL_POS, null);
16451            }
16452    
16453            /**
16454             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
16455             *
16456             * <p>
16457             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16458             * </p>
16459             *
16460             * @param groupId the group ID
16461             * @param classNameId the class name ID
16462             * @param classPK the class p k
16463             * @param start the lower bound of the range of journal articles
16464             * @param end the upper bound of the range of journal articles (not inclusive)
16465             * @return the range of matching journal articles
16466             * @throws SystemException if a system exception occurred
16467             */
16468            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
16469                    long classPK, int start, int end) throws SystemException {
16470                    return findByG_C_C(groupId, classNameId, classPK, start, end, null);
16471            }
16472    
16473            /**
16474             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
16475             *
16476             * <p>
16477             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16478             * </p>
16479             *
16480             * @param groupId the group ID
16481             * @param classNameId the class name ID
16482             * @param classPK the class p k
16483             * @param start the lower bound of the range of journal articles
16484             * @param end the upper bound of the range of journal articles (not inclusive)
16485             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16486             * @return the ordered range of matching journal articles
16487             * @throws SystemException if a system exception occurred
16488             */
16489            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
16490                    long classPK, int start, int end, OrderByComparator orderByComparator)
16491                    throws SystemException {
16492                    boolean pagination = true;
16493                    FinderPath finderPath = null;
16494                    Object[] finderArgs = null;
16495    
16496                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
16497                                    (orderByComparator == null)) {
16498                            pagination = false;
16499                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C;
16500                            finderArgs = new Object[] { groupId, classNameId, classPK };
16501                    }
16502                    else {
16503                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C;
16504                            finderArgs = new Object[] {
16505                                            groupId, classNameId, classPK,
16506                                            
16507                                            start, end, orderByComparator
16508                                    };
16509                    }
16510    
16511                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
16512                                    finderArgs, this);
16513    
16514                    if ((list != null) && !list.isEmpty()) {
16515                            for (JournalArticle journalArticle : list) {
16516                                    if ((groupId != journalArticle.getGroupId()) ||
16517                                                    (classNameId != journalArticle.getClassNameId()) ||
16518                                                    (classPK != journalArticle.getClassPK())) {
16519                                            list = null;
16520    
16521                                            break;
16522                                    }
16523                            }
16524                    }
16525    
16526                    if (list == null) {
16527                            StringBundler query = null;
16528    
16529                            if (orderByComparator != null) {
16530                                    query = new StringBundler(5 +
16531                                                    (orderByComparator.getOrderByFields().length * 3));
16532                            }
16533                            else {
16534                                    query = new StringBundler(5);
16535                            }
16536    
16537                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16538    
16539                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
16540    
16541                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
16542    
16543                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
16544    
16545                            if (orderByComparator != null) {
16546                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16547                                            orderByComparator);
16548                            }
16549                            else
16550                             if (pagination) {
16551                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16552                            }
16553    
16554                            String sql = query.toString();
16555    
16556                            Session session = null;
16557    
16558                            try {
16559                                    session = openSession();
16560    
16561                                    Query q = session.createQuery(sql);
16562    
16563                                    QueryPos qPos = QueryPos.getInstance(q);
16564    
16565                                    qPos.add(groupId);
16566    
16567                                    qPos.add(classNameId);
16568    
16569                                    qPos.add(classPK);
16570    
16571                                    if (!pagination) {
16572                                            list = (List<JournalArticle>)QueryUtil.list(q,
16573                                                            getDialect(), start, end, false);
16574    
16575                                            Collections.sort(list);
16576    
16577                                            list = new UnmodifiableList<JournalArticle>(list);
16578                                    }
16579                                    else {
16580                                            list = (List<JournalArticle>)QueryUtil.list(q,
16581                                                            getDialect(), start, end);
16582                                    }
16583    
16584                                    cacheResult(list);
16585    
16586                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
16587                            }
16588                            catch (Exception e) {
16589                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16590    
16591                                    throw processException(e);
16592                            }
16593                            finally {
16594                                    closeSession(session);
16595                            }
16596                    }
16597    
16598                    return list;
16599            }
16600    
16601            /**
16602             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
16603             *
16604             * @param groupId the group ID
16605             * @param classNameId the class name ID
16606             * @param classPK the class p k
16607             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16608             * @return the first matching journal article
16609             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
16610             * @throws SystemException if a system exception occurred
16611             */
16612            public JournalArticle findByG_C_C_First(long groupId, long classNameId,
16613                    long classPK, OrderByComparator orderByComparator)
16614                    throws NoSuchArticleException, SystemException {
16615                    JournalArticle journalArticle = fetchByG_C_C_First(groupId,
16616                                    classNameId, classPK, orderByComparator);
16617    
16618                    if (journalArticle != null) {
16619                            return journalArticle;
16620                    }
16621    
16622                    StringBundler msg = new StringBundler(8);
16623    
16624                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16625    
16626                    msg.append("groupId=");
16627                    msg.append(groupId);
16628    
16629                    msg.append(", classNameId=");
16630                    msg.append(classNameId);
16631    
16632                    msg.append(", classPK=");
16633                    msg.append(classPK);
16634    
16635                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16636    
16637                    throw new NoSuchArticleException(msg.toString());
16638            }
16639    
16640            /**
16641             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
16642             *
16643             * @param groupId the group ID
16644             * @param classNameId the class name ID
16645             * @param classPK the class p k
16646             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16647             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
16648             * @throws SystemException if a system exception occurred
16649             */
16650            public JournalArticle fetchByG_C_C_First(long groupId, long classNameId,
16651                    long classPK, OrderByComparator orderByComparator)
16652                    throws SystemException {
16653                    List<JournalArticle> list = findByG_C_C(groupId, classNameId, classPK,
16654                                    0, 1, orderByComparator);
16655    
16656                    if (!list.isEmpty()) {
16657                            return list.get(0);
16658                    }
16659    
16660                    return null;
16661            }
16662    
16663            /**
16664             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
16665             *
16666             * @param groupId the group ID
16667             * @param classNameId the class name ID
16668             * @param classPK the class p k
16669             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16670             * @return the last matching journal article
16671             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
16672             * @throws SystemException if a system exception occurred
16673             */
16674            public JournalArticle findByG_C_C_Last(long groupId, long classNameId,
16675                    long classPK, OrderByComparator orderByComparator)
16676                    throws NoSuchArticleException, SystemException {
16677                    JournalArticle journalArticle = fetchByG_C_C_Last(groupId, classNameId,
16678                                    classPK, orderByComparator);
16679    
16680                    if (journalArticle != null) {
16681                            return journalArticle;
16682                    }
16683    
16684                    StringBundler msg = new StringBundler(8);
16685    
16686                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16687    
16688                    msg.append("groupId=");
16689                    msg.append(groupId);
16690    
16691                    msg.append(", classNameId=");
16692                    msg.append(classNameId);
16693    
16694                    msg.append(", classPK=");
16695                    msg.append(classPK);
16696    
16697                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16698    
16699                    throw new NoSuchArticleException(msg.toString());
16700            }
16701    
16702            /**
16703             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
16704             *
16705             * @param groupId the group ID
16706             * @param classNameId the class name ID
16707             * @param classPK the class p k
16708             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16709             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
16710             * @throws SystemException if a system exception occurred
16711             */
16712            public JournalArticle fetchByG_C_C_Last(long groupId, long classNameId,
16713                    long classPK, OrderByComparator orderByComparator)
16714                    throws SystemException {
16715                    int count = countByG_C_C(groupId, classNameId, classPK);
16716    
16717                    List<JournalArticle> list = findByG_C_C(groupId, classNameId, classPK,
16718                                    count - 1, count, orderByComparator);
16719    
16720                    if (!list.isEmpty()) {
16721                            return list.get(0);
16722                    }
16723    
16724                    return null;
16725            }
16726    
16727            /**
16728             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
16729             *
16730             * @param id the primary key of the current journal article
16731             * @param groupId the group ID
16732             * @param classNameId the class name ID
16733             * @param classPK the class p k
16734             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16735             * @return the previous, current, and next journal article
16736             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
16737             * @throws SystemException if a system exception occurred
16738             */
16739            public JournalArticle[] findByG_C_C_PrevAndNext(long id, long groupId,
16740                    long classNameId, long classPK, OrderByComparator orderByComparator)
16741                    throws NoSuchArticleException, SystemException {
16742                    JournalArticle journalArticle = findByPrimaryKey(id);
16743    
16744                    Session session = null;
16745    
16746                    try {
16747                            session = openSession();
16748    
16749                            JournalArticle[] array = new JournalArticleImpl[3];
16750    
16751                            array[0] = getByG_C_C_PrevAndNext(session, journalArticle, groupId,
16752                                            classNameId, classPK, orderByComparator, true);
16753    
16754                            array[1] = journalArticle;
16755    
16756                            array[2] = getByG_C_C_PrevAndNext(session, journalArticle, groupId,
16757                                            classNameId, classPK, orderByComparator, false);
16758    
16759                            return array;
16760                    }
16761                    catch (Exception e) {
16762                            throw processException(e);
16763                    }
16764                    finally {
16765                            closeSession(session);
16766                    }
16767            }
16768    
16769            protected JournalArticle getByG_C_C_PrevAndNext(Session session,
16770                    JournalArticle journalArticle, long groupId, long classNameId,
16771                    long classPK, OrderByComparator orderByComparator, boolean previous) {
16772                    StringBundler query = null;
16773    
16774                    if (orderByComparator != null) {
16775                            query = new StringBundler(6 +
16776                                            (orderByComparator.getOrderByFields().length * 6));
16777                    }
16778                    else {
16779                            query = new StringBundler(3);
16780                    }
16781    
16782                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16783    
16784                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
16785    
16786                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
16787    
16788                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
16789    
16790                    if (orderByComparator != null) {
16791                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16792    
16793                            if (orderByConditionFields.length > 0) {
16794                                    query.append(WHERE_AND);
16795                            }
16796    
16797                            for (int i = 0; i < orderByConditionFields.length; i++) {
16798                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16799                                    query.append(orderByConditionFields[i]);
16800    
16801                                    if ((i + 1) < orderByConditionFields.length) {
16802                                            if (orderByComparator.isAscending() ^ previous) {
16803                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16804                                            }
16805                                            else {
16806                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16807                                            }
16808                                    }
16809                                    else {
16810                                            if (orderByComparator.isAscending() ^ previous) {
16811                                                    query.append(WHERE_GREATER_THAN);
16812                                            }
16813                                            else {
16814                                                    query.append(WHERE_LESSER_THAN);
16815                                            }
16816                                    }
16817                            }
16818    
16819                            query.append(ORDER_BY_CLAUSE);
16820    
16821                            String[] orderByFields = orderByComparator.getOrderByFields();
16822    
16823                            for (int i = 0; i < orderByFields.length; i++) {
16824                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16825                                    query.append(orderByFields[i]);
16826    
16827                                    if ((i + 1) < orderByFields.length) {
16828                                            if (orderByComparator.isAscending() ^ previous) {
16829                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16830                                            }
16831                                            else {
16832                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16833                                            }
16834                                    }
16835                                    else {
16836                                            if (orderByComparator.isAscending() ^ previous) {
16837                                                    query.append(ORDER_BY_ASC);
16838                                            }
16839                                            else {
16840                                                    query.append(ORDER_BY_DESC);
16841                                            }
16842                                    }
16843                            }
16844                    }
16845                    else {
16846                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16847                    }
16848    
16849                    String sql = query.toString();
16850    
16851                    Query q = session.createQuery(sql);
16852    
16853                    q.setFirstResult(0);
16854                    q.setMaxResults(2);
16855    
16856                    QueryPos qPos = QueryPos.getInstance(q);
16857    
16858                    qPos.add(groupId);
16859    
16860                    qPos.add(classNameId);
16861    
16862                    qPos.add(classPK);
16863    
16864                    if (orderByComparator != null) {
16865                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
16866    
16867                            for (Object value : values) {
16868                                    qPos.add(value);
16869                            }
16870                    }
16871    
16872                    List<JournalArticle> list = q.list();
16873    
16874                    if (list.size() == 2) {
16875                            return list.get(1);
16876                    }
16877                    else {
16878                            return null;
16879                    }
16880            }
16881    
16882            /**
16883             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
16884             *
16885             * @param groupId the group ID
16886             * @param classNameId the class name ID
16887             * @param classPK the class p k
16888             * @return the matching journal articles that the user has permission to view
16889             * @throws SystemException if a system exception occurred
16890             */
16891            public List<JournalArticle> filterFindByG_C_C(long groupId,
16892                    long classNameId, long classPK) throws SystemException {
16893                    return filterFindByG_C_C(groupId, classNameId, classPK,
16894                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
16895            }
16896    
16897            /**
16898             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
16899             *
16900             * <p>
16901             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16902             * </p>
16903             *
16904             * @param groupId the group ID
16905             * @param classNameId the class name ID
16906             * @param classPK the class p k
16907             * @param start the lower bound of the range of journal articles
16908             * @param end the upper bound of the range of journal articles (not inclusive)
16909             * @return the range of matching journal articles that the user has permission to view
16910             * @throws SystemException if a system exception occurred
16911             */
16912            public List<JournalArticle> filterFindByG_C_C(long groupId,
16913                    long classNameId, long classPK, int start, int end)
16914                    throws SystemException {
16915                    return filterFindByG_C_C(groupId, classNameId, classPK, start, end, null);
16916            }
16917    
16918            /**
16919             * 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;.
16920             *
16921             * <p>
16922             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16923             * </p>
16924             *
16925             * @param groupId the group ID
16926             * @param classNameId the class name ID
16927             * @param classPK the class p k
16928             * @param start the lower bound of the range of journal articles
16929             * @param end the upper bound of the range of journal articles (not inclusive)
16930             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16931             * @return the ordered range of matching journal articles that the user has permission to view
16932             * @throws SystemException if a system exception occurred
16933             */
16934            public List<JournalArticle> filterFindByG_C_C(long groupId,
16935                    long classNameId, long classPK, int start, int end,
16936                    OrderByComparator orderByComparator) throws SystemException {
16937                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16938                            return findByG_C_C(groupId, classNameId, classPK, start, end,
16939                                    orderByComparator);
16940                    }
16941    
16942                    StringBundler query = null;
16943    
16944                    if (orderByComparator != null) {
16945                            query = new StringBundler(5 +
16946                                            (orderByComparator.getOrderByFields().length * 3));
16947                    }
16948                    else {
16949                            query = new StringBundler(5);
16950                    }
16951    
16952                    if (getDB().isSupportsInlineDistinct()) {
16953                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
16954                    }
16955                    else {
16956                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
16957                    }
16958    
16959                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
16960    
16961                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
16962    
16963                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
16964    
16965                    if (!getDB().isSupportsInlineDistinct()) {
16966                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
16967                    }
16968    
16969                    if (orderByComparator != null) {
16970                            if (getDB().isSupportsInlineDistinct()) {
16971                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16972                                            orderByComparator);
16973                            }
16974                            else {
16975                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
16976                                            orderByComparator);
16977                            }
16978                    }
16979                    else {
16980                            if (getDB().isSupportsInlineDistinct()) {
16981                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16982                            }
16983                            else {
16984                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
16985                            }
16986                    }
16987    
16988                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16989                                    JournalArticle.class.getName(),
16990                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16991    
16992                    Session session = null;
16993    
16994                    try {
16995                            session = openSession();
16996    
16997                            SQLQuery q = session.createSQLQuery(sql);
16998    
16999                            if (getDB().isSupportsInlineDistinct()) {
17000                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
17001                            }
17002                            else {
17003                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
17004                            }
17005    
17006                            QueryPos qPos = QueryPos.getInstance(q);
17007    
17008                            qPos.add(groupId);
17009    
17010                            qPos.add(classNameId);
17011    
17012                            qPos.add(classPK);
17013    
17014                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
17015                                    end);
17016                    }
17017                    catch (Exception e) {
17018                            throw processException(e);
17019                    }
17020                    finally {
17021                            closeSession(session);
17022                    }
17023            }
17024    
17025            /**
17026             * 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;.
17027             *
17028             * @param id the primary key of the current journal article
17029             * @param groupId the group ID
17030             * @param classNameId the class name ID
17031             * @param classPK the class p k
17032             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17033             * @return the previous, current, and next journal article
17034             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
17035             * @throws SystemException if a system exception occurred
17036             */
17037            public JournalArticle[] filterFindByG_C_C_PrevAndNext(long id,
17038                    long groupId, long classNameId, long classPK,
17039                    OrderByComparator orderByComparator)
17040                    throws NoSuchArticleException, SystemException {
17041                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17042                            return findByG_C_C_PrevAndNext(id, groupId, classNameId, classPK,
17043                                    orderByComparator);
17044                    }
17045    
17046                    JournalArticle journalArticle = findByPrimaryKey(id);
17047    
17048                    Session session = null;
17049    
17050                    try {
17051                            session = openSession();
17052    
17053                            JournalArticle[] array = new JournalArticleImpl[3];
17054    
17055                            array[0] = filterGetByG_C_C_PrevAndNext(session, journalArticle,
17056                                            groupId, classNameId, classPK, orderByComparator, true);
17057    
17058                            array[1] = journalArticle;
17059    
17060                            array[2] = filterGetByG_C_C_PrevAndNext(session, journalArticle,
17061                                            groupId, classNameId, classPK, orderByComparator, false);
17062    
17063                            return array;
17064                    }
17065                    catch (Exception e) {
17066                            throw processException(e);
17067                    }
17068                    finally {
17069                            closeSession(session);
17070                    }
17071            }
17072    
17073            protected JournalArticle filterGetByG_C_C_PrevAndNext(Session session,
17074                    JournalArticle journalArticle, long groupId, long classNameId,
17075                    long classPK, OrderByComparator orderByComparator, boolean previous) {
17076                    StringBundler query = null;
17077    
17078                    if (orderByComparator != null) {
17079                            query = new StringBundler(6 +
17080                                            (orderByComparator.getOrderByFields().length * 6));
17081                    }
17082                    else {
17083                            query = new StringBundler(3);
17084                    }
17085    
17086                    if (getDB().isSupportsInlineDistinct()) {
17087                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
17088                    }
17089                    else {
17090                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
17091                    }
17092    
17093                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
17094    
17095                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
17096    
17097                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
17098    
17099                    if (!getDB().isSupportsInlineDistinct()) {
17100                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
17101                    }
17102    
17103                    if (orderByComparator != null) {
17104                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17105    
17106                            if (orderByConditionFields.length > 0) {
17107                                    query.append(WHERE_AND);
17108                            }
17109    
17110                            for (int i = 0; i < orderByConditionFields.length; i++) {
17111                                    if (getDB().isSupportsInlineDistinct()) {
17112                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17113                                    }
17114                                    else {
17115                                            query.append(_ORDER_BY_ENTITY_TABLE);
17116                                    }
17117    
17118                                    query.append(orderByConditionFields[i]);
17119    
17120                                    if ((i + 1) < orderByConditionFields.length) {
17121                                            if (orderByComparator.isAscending() ^ previous) {
17122                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17123                                            }
17124                                            else {
17125                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17126                                            }
17127                                    }
17128                                    else {
17129                                            if (orderByComparator.isAscending() ^ previous) {
17130                                                    query.append(WHERE_GREATER_THAN);
17131                                            }
17132                                            else {
17133                                                    query.append(WHERE_LESSER_THAN);
17134                                            }
17135                                    }
17136                            }
17137    
17138                            query.append(ORDER_BY_CLAUSE);
17139    
17140                            String[] orderByFields = orderByComparator.getOrderByFields();
17141    
17142                            for (int i = 0; i < orderByFields.length; i++) {
17143                                    if (getDB().isSupportsInlineDistinct()) {
17144                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17145                                    }
17146                                    else {
17147                                            query.append(_ORDER_BY_ENTITY_TABLE);
17148                                    }
17149    
17150                                    query.append(orderByFields[i]);
17151    
17152                                    if ((i + 1) < orderByFields.length) {
17153                                            if (orderByComparator.isAscending() ^ previous) {
17154                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17155                                            }
17156                                            else {
17157                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17158                                            }
17159                                    }
17160                                    else {
17161                                            if (orderByComparator.isAscending() ^ previous) {
17162                                                    query.append(ORDER_BY_ASC);
17163                                            }
17164                                            else {
17165                                                    query.append(ORDER_BY_DESC);
17166                                            }
17167                                    }
17168                            }
17169                    }
17170                    else {
17171                            if (getDB().isSupportsInlineDistinct()) {
17172                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17173                            }
17174                            else {
17175                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
17176                            }
17177                    }
17178    
17179                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17180                                    JournalArticle.class.getName(),
17181                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17182    
17183                    SQLQuery q = session.createSQLQuery(sql);
17184    
17185                    q.setFirstResult(0);
17186                    q.setMaxResults(2);
17187    
17188                    if (getDB().isSupportsInlineDistinct()) {
17189                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
17190                    }
17191                    else {
17192                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
17193                    }
17194    
17195                    QueryPos qPos = QueryPos.getInstance(q);
17196    
17197                    qPos.add(groupId);
17198    
17199                    qPos.add(classNameId);
17200    
17201                    qPos.add(classPK);
17202    
17203                    if (orderByComparator != null) {
17204                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
17205    
17206                            for (Object value : values) {
17207                                    qPos.add(value);
17208                            }
17209                    }
17210    
17211                    List<JournalArticle> list = q.list();
17212    
17213                    if (list.size() == 2) {
17214                            return list.get(1);
17215                    }
17216                    else {
17217                            return null;
17218                    }
17219            }
17220    
17221            /**
17222             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63; from the database.
17223             *
17224             * @param groupId the group ID
17225             * @param classNameId the class name ID
17226             * @param classPK the class p k
17227             * @throws SystemException if a system exception occurred
17228             */
17229            public void removeByG_C_C(long groupId, long classNameId, long classPK)
17230                    throws SystemException {
17231                    for (JournalArticle journalArticle : findByG_C_C(groupId, classNameId,
17232                                    classPK, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
17233                            remove(journalArticle);
17234                    }
17235            }
17236    
17237            /**
17238             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
17239             *
17240             * @param groupId the group ID
17241             * @param classNameId the class name ID
17242             * @param classPK the class p k
17243             * @return the number of matching journal articles
17244             * @throws SystemException if a system exception occurred
17245             */
17246            public int countByG_C_C(long groupId, long classNameId, long classPK)
17247                    throws SystemException {
17248                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_C;
17249    
17250                    Object[] finderArgs = new Object[] { groupId, classNameId, classPK };
17251    
17252                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
17253                                    this);
17254    
17255                    if (count == null) {
17256                            StringBundler query = new StringBundler(4);
17257    
17258                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17259    
17260                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
17261    
17262                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
17263    
17264                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
17265    
17266                            String sql = query.toString();
17267    
17268                            Session session = null;
17269    
17270                            try {
17271                                    session = openSession();
17272    
17273                                    Query q = session.createQuery(sql);
17274    
17275                                    QueryPos qPos = QueryPos.getInstance(q);
17276    
17277                                    qPos.add(groupId);
17278    
17279                                    qPos.add(classNameId);
17280    
17281                                    qPos.add(classPK);
17282    
17283                                    count = (Long)q.uniqueResult();
17284    
17285                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
17286                            }
17287                            catch (Exception e) {
17288                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17289    
17290                                    throw processException(e);
17291                            }
17292                            finally {
17293                                    closeSession(session);
17294                            }
17295                    }
17296    
17297                    return count.intValue();
17298            }
17299    
17300            /**
17301             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
17302             *
17303             * @param groupId the group ID
17304             * @param classNameId the class name ID
17305             * @param classPK the class p k
17306             * @return the number of matching journal articles that the user has permission to view
17307             * @throws SystemException if a system exception occurred
17308             */
17309            public int filterCountByG_C_C(long groupId, long classNameId, long classPK)
17310                    throws SystemException {
17311                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17312                            return countByG_C_C(groupId, classNameId, classPK);
17313                    }
17314    
17315                    StringBundler query = new StringBundler(4);
17316    
17317                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
17318    
17319                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
17320    
17321                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
17322    
17323                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
17324    
17325                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17326                                    JournalArticle.class.getName(),
17327                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17328    
17329                    Session session = null;
17330    
17331                    try {
17332                            session = openSession();
17333    
17334                            SQLQuery q = session.createSQLQuery(sql);
17335    
17336                            q.addScalar(COUNT_COLUMN_NAME,
17337                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17338    
17339                            QueryPos qPos = QueryPos.getInstance(q);
17340    
17341                            qPos.add(groupId);
17342    
17343                            qPos.add(classNameId);
17344    
17345                            qPos.add(classPK);
17346    
17347                            Long count = (Long)q.uniqueResult();
17348    
17349                            return count.intValue();
17350                    }
17351                    catch (Exception e) {
17352                            throw processException(e);
17353                    }
17354                    finally {
17355                            closeSession(session);
17356                    }
17357            }
17358    
17359            private static final String _FINDER_COLUMN_G_C_C_GROUPID_2 = "journalArticle.groupId = ? AND ";
17360            private static final String _FINDER_COLUMN_G_C_C_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
17361            private static final String _FINDER_COLUMN_G_C_C_CLASSPK_2 = "journalArticle.classPK = ?";
17362            public static final FinderPath FINDER_PATH_FETCH_BY_G_C_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17363                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
17364                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_C_S",
17365                            new String[] {
17366                                    Long.class.getName(), Long.class.getName(),
17367                                    String.class.getName()
17368                            },
17369                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
17370                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
17371                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK);
17372            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17373                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
17374                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_S",
17375                            new String[] {
17376                                    Long.class.getName(), Long.class.getName(),
17377                                    String.class.getName()
17378                            });
17379    
17380            /**
17381             * 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.
17382             *
17383             * @param groupId the group ID
17384             * @param classNameId the class name ID
17385             * @param structureId the structure ID
17386             * @return the matching journal article
17387             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
17388             * @throws SystemException if a system exception occurred
17389             */
17390            public JournalArticle findByG_C_S(long groupId, long classNameId,
17391                    String structureId) throws NoSuchArticleException, SystemException {
17392                    JournalArticle journalArticle = fetchByG_C_S(groupId, classNameId,
17393                                    structureId);
17394    
17395                    if (journalArticle == null) {
17396                            StringBundler msg = new StringBundler(8);
17397    
17398                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17399    
17400                            msg.append("groupId=");
17401                            msg.append(groupId);
17402    
17403                            msg.append(", classNameId=");
17404                            msg.append(classNameId);
17405    
17406                            msg.append(", structureId=");
17407                            msg.append(structureId);
17408    
17409                            msg.append(StringPool.CLOSE_CURLY_BRACE);
17410    
17411                            if (_log.isWarnEnabled()) {
17412                                    _log.warn(msg.toString());
17413                            }
17414    
17415                            throw new NoSuchArticleException(msg.toString());
17416                    }
17417    
17418                    return journalArticle;
17419            }
17420    
17421            /**
17422             * 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.
17423             *
17424             * @param groupId the group ID
17425             * @param classNameId the class name ID
17426             * @param structureId the structure ID
17427             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
17428             * @throws SystemException if a system exception occurred
17429             */
17430            public JournalArticle fetchByG_C_S(long groupId, long classNameId,
17431                    String structureId) throws SystemException {
17432                    return fetchByG_C_S(groupId, classNameId, structureId, true);
17433            }
17434    
17435            /**
17436             * 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.
17437             *
17438             * @param groupId the group ID
17439             * @param classNameId the class name ID
17440             * @param structureId the structure ID
17441             * @param retrieveFromCache whether to use the finder cache
17442             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
17443             * @throws SystemException if a system exception occurred
17444             */
17445            public JournalArticle fetchByG_C_S(long groupId, long classNameId,
17446                    String structureId, boolean retrieveFromCache)
17447                    throws SystemException {
17448                    Object[] finderArgs = new Object[] { groupId, classNameId, structureId };
17449    
17450                    Object result = null;
17451    
17452                    if (retrieveFromCache) {
17453                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_C_S,
17454                                            finderArgs, this);
17455                    }
17456    
17457                    if (result instanceof JournalArticle) {
17458                            JournalArticle journalArticle = (JournalArticle)result;
17459    
17460                            if ((groupId != journalArticle.getGroupId()) ||
17461                                            (classNameId != journalArticle.getClassNameId()) ||
17462                                            !Validator.equals(structureId,
17463                                                    journalArticle.getStructureId())) {
17464                                    result = null;
17465                            }
17466                    }
17467    
17468                    if (result == null) {
17469                            StringBundler query = new StringBundler(5);
17470    
17471                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17472    
17473                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
17474    
17475                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
17476    
17477                            if (structureId == null) {
17478                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_1);
17479                            }
17480                            else {
17481                                    if (structureId.equals(StringPool.BLANK)) {
17482                                            query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_3);
17483                                    }
17484                                    else {
17485                                            query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_2);
17486                                    }
17487                            }
17488    
17489                            String sql = query.toString();
17490    
17491                            Session session = null;
17492    
17493                            try {
17494                                    session = openSession();
17495    
17496                                    Query q = session.createQuery(sql);
17497    
17498                                    QueryPos qPos = QueryPos.getInstance(q);
17499    
17500                                    qPos.add(groupId);
17501    
17502                                    qPos.add(classNameId);
17503    
17504                                    if (structureId != null) {
17505                                            qPos.add(structureId);
17506                                    }
17507    
17508                                    List<JournalArticle> list = q.list();
17509    
17510                                    if (list.isEmpty()) {
17511                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
17512                                                    finderArgs, list);
17513                                    }
17514                                    else {
17515                                            if ((list.size() > 1) && _log.isWarnEnabled()) {
17516                                                    _log.warn(
17517                                                            "JournalArticlePersistenceImpl.fetchByG_C_S(long, long, String, boolean) with parameters (" +
17518                                                            StringUtil.merge(finderArgs) +
17519                                                            ") 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.");
17520                                            }
17521    
17522                                            JournalArticle journalArticle = list.get(0);
17523    
17524                                            result = journalArticle;
17525    
17526                                            cacheResult(journalArticle);
17527    
17528                                            if ((journalArticle.getGroupId() != groupId) ||
17529                                                            (journalArticle.getClassNameId() != classNameId) ||
17530                                                            (journalArticle.getStructureId() == null) ||
17531                                                            !journalArticle.getStructureId().equals(structureId)) {
17532                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
17533                                                            finderArgs, journalArticle);
17534                                            }
17535                                    }
17536                            }
17537                            catch (Exception e) {
17538                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S,
17539                                            finderArgs);
17540    
17541                                    throw processException(e);
17542                            }
17543                            finally {
17544                                    closeSession(session);
17545                            }
17546                    }
17547    
17548                    if (result instanceof List<?>) {
17549                            return null;
17550                    }
17551                    else {
17552                            return (JournalArticle)result;
17553                    }
17554            }
17555    
17556            /**
17557             * Removes the journal article where groupId = &#63; and classNameId = &#63; and structureId = &#63; from the database.
17558             *
17559             * @param groupId the group ID
17560             * @param classNameId the class name ID
17561             * @param structureId the structure ID
17562             * @return the journal article that was removed
17563             * @throws SystemException if a system exception occurred
17564             */
17565            public JournalArticle removeByG_C_S(long groupId, long classNameId,
17566                    String structureId) throws NoSuchArticleException, SystemException {
17567                    JournalArticle journalArticle = findByG_C_S(groupId, classNameId,
17568                                    structureId);
17569    
17570                    return remove(journalArticle);
17571            }
17572    
17573            /**
17574             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and structureId = &#63;.
17575             *
17576             * @param groupId the group ID
17577             * @param classNameId the class name ID
17578             * @param structureId the structure ID
17579             * @return the number of matching journal articles
17580             * @throws SystemException if a system exception occurred
17581             */
17582            public int countByG_C_S(long groupId, long classNameId, String structureId)
17583                    throws SystemException {
17584                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_S;
17585    
17586                    Object[] finderArgs = new Object[] { groupId, classNameId, structureId };
17587    
17588                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
17589                                    this);
17590    
17591                    if (count == null) {
17592                            StringBundler query = new StringBundler(4);
17593    
17594                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17595    
17596                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
17597    
17598                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
17599    
17600                            if (structureId == null) {
17601                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_1);
17602                            }
17603                            else {
17604                                    if (structureId.equals(StringPool.BLANK)) {
17605                                            query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_3);
17606                                    }
17607                                    else {
17608                                            query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_2);
17609                                    }
17610                            }
17611    
17612                            String sql = query.toString();
17613    
17614                            Session session = null;
17615    
17616                            try {
17617                                    session = openSession();
17618    
17619                                    Query q = session.createQuery(sql);
17620    
17621                                    QueryPos qPos = QueryPos.getInstance(q);
17622    
17623                                    qPos.add(groupId);
17624    
17625                                    qPos.add(classNameId);
17626    
17627                                    if (structureId != null) {
17628                                            qPos.add(structureId);
17629                                    }
17630    
17631                                    count = (Long)q.uniqueResult();
17632    
17633                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
17634                            }
17635                            catch (Exception e) {
17636                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17637    
17638                                    throw processException(e);
17639                            }
17640                            finally {
17641                                    closeSession(session);
17642                            }
17643                    }
17644    
17645                    return count.intValue();
17646            }
17647    
17648            private static final String _FINDER_COLUMN_G_C_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
17649            private static final String _FINDER_COLUMN_G_C_S_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
17650            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
17651            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
17652            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = ?)";
17653            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17654                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
17655                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
17656                            "findByG_C_T",
17657                            new String[] {
17658                                    Long.class.getName(), Long.class.getName(),
17659                                    String.class.getName(),
17660                                    
17661                            Integer.class.getName(), Integer.class.getName(),
17662                                    OrderByComparator.class.getName()
17663                            });
17664            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17665                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
17666                            JournalArticleImpl.class,
17667                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_T",
17668                            new String[] {
17669                                    Long.class.getName(), Long.class.getName(),
17670                                    String.class.getName()
17671                            },
17672                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
17673                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
17674                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK |
17675                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
17676                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
17677            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17678                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
17679                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_T",
17680                            new String[] {
17681                                    Long.class.getName(), Long.class.getName(),
17682                                    String.class.getName()
17683                            });
17684    
17685            /**
17686             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
17687             *
17688             * @param groupId the group ID
17689             * @param classNameId the class name ID
17690             * @param templateId the template ID
17691             * @return the matching journal articles
17692             * @throws SystemException if a system exception occurred
17693             */
17694            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
17695                    String templateId) throws SystemException {
17696                    return findByG_C_T(groupId, classNameId, templateId, QueryUtil.ALL_POS,
17697                            QueryUtil.ALL_POS, null);
17698            }
17699    
17700            /**
17701             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
17702             *
17703             * <p>
17704             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17705             * </p>
17706             *
17707             * @param groupId the group ID
17708             * @param classNameId the class name ID
17709             * @param templateId the template ID
17710             * @param start the lower bound of the range of journal articles
17711             * @param end the upper bound of the range of journal articles (not inclusive)
17712             * @return the range of matching journal articles
17713             * @throws SystemException if a system exception occurred
17714             */
17715            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
17716                    String templateId, int start, int end) throws SystemException {
17717                    return findByG_C_T(groupId, classNameId, templateId, start, end, null);
17718            }
17719    
17720            /**
17721             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
17722             *
17723             * <p>
17724             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17725             * </p>
17726             *
17727             * @param groupId the group ID
17728             * @param classNameId the class name ID
17729             * @param templateId the template ID
17730             * @param start the lower bound of the range of journal articles
17731             * @param end the upper bound of the range of journal articles (not inclusive)
17732             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17733             * @return the ordered range of matching journal articles
17734             * @throws SystemException if a system exception occurred
17735             */
17736            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
17737                    String templateId, int start, int end,
17738                    OrderByComparator orderByComparator) throws SystemException {
17739                    boolean pagination = true;
17740                    FinderPath finderPath = null;
17741                    Object[] finderArgs = null;
17742    
17743                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
17744                                    (orderByComparator == null)) {
17745                            pagination = false;
17746                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T;
17747                            finderArgs = new Object[] { groupId, classNameId, templateId };
17748                    }
17749                    else {
17750                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T;
17751                            finderArgs = new Object[] {
17752                                            groupId, classNameId, templateId,
17753                                            
17754                                            start, end, orderByComparator
17755                                    };
17756                    }
17757    
17758                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
17759                                    finderArgs, this);
17760    
17761                    if ((list != null) && !list.isEmpty()) {
17762                            for (JournalArticle journalArticle : list) {
17763                                    if ((groupId != journalArticle.getGroupId()) ||
17764                                                    (classNameId != journalArticle.getClassNameId()) ||
17765                                                    !Validator.equals(templateId,
17766                                                            journalArticle.getTemplateId())) {
17767                                            list = null;
17768    
17769                                            break;
17770                                    }
17771                            }
17772                    }
17773    
17774                    if (list == null) {
17775                            StringBundler query = null;
17776    
17777                            if (orderByComparator != null) {
17778                                    query = new StringBundler(5 +
17779                                                    (orderByComparator.getOrderByFields().length * 3));
17780                            }
17781                            else {
17782                                    query = new StringBundler(5);
17783                            }
17784    
17785                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17786    
17787                            query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
17788    
17789                            query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
17790    
17791                            if (templateId == null) {
17792                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
17793                            }
17794                            else {
17795                                    if (templateId.equals(StringPool.BLANK)) {
17796                                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
17797                                    }
17798                                    else {
17799                                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
17800                                    }
17801                            }
17802    
17803                            if (orderByComparator != null) {
17804                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17805                                            orderByComparator);
17806                            }
17807                            else
17808                             if (pagination) {
17809                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17810                            }
17811    
17812                            String sql = query.toString();
17813    
17814                            Session session = null;
17815    
17816                            try {
17817                                    session = openSession();
17818    
17819                                    Query q = session.createQuery(sql);
17820    
17821                                    QueryPos qPos = QueryPos.getInstance(q);
17822    
17823                                    qPos.add(groupId);
17824    
17825                                    qPos.add(classNameId);
17826    
17827                                    if (templateId != null) {
17828                                            qPos.add(templateId);
17829                                    }
17830    
17831                                    if (!pagination) {
17832                                            list = (List<JournalArticle>)QueryUtil.list(q,
17833                                                            getDialect(), start, end, false);
17834    
17835                                            Collections.sort(list);
17836    
17837                                            list = new UnmodifiableList<JournalArticle>(list);
17838                                    }
17839                                    else {
17840                                            list = (List<JournalArticle>)QueryUtil.list(q,
17841                                                            getDialect(), start, end);
17842                                    }
17843    
17844                                    cacheResult(list);
17845    
17846                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
17847                            }
17848                            catch (Exception e) {
17849                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17850    
17851                                    throw processException(e);
17852                            }
17853                            finally {
17854                                    closeSession(session);
17855                            }
17856                    }
17857    
17858                    return list;
17859            }
17860    
17861            /**
17862             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
17863             *
17864             * @param groupId the group ID
17865             * @param classNameId the class name ID
17866             * @param templateId the template ID
17867             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17868             * @return the first matching journal article
17869             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
17870             * @throws SystemException if a system exception occurred
17871             */
17872            public JournalArticle findByG_C_T_First(long groupId, long classNameId,
17873                    String templateId, OrderByComparator orderByComparator)
17874                    throws NoSuchArticleException, SystemException {
17875                    JournalArticle journalArticle = fetchByG_C_T_First(groupId,
17876                                    classNameId, templateId, orderByComparator);
17877    
17878                    if (journalArticle != null) {
17879                            return journalArticle;
17880                    }
17881    
17882                    StringBundler msg = new StringBundler(8);
17883    
17884                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17885    
17886                    msg.append("groupId=");
17887                    msg.append(groupId);
17888    
17889                    msg.append(", classNameId=");
17890                    msg.append(classNameId);
17891    
17892                    msg.append(", templateId=");
17893                    msg.append(templateId);
17894    
17895                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17896    
17897                    throw new NoSuchArticleException(msg.toString());
17898            }
17899    
17900            /**
17901             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
17902             *
17903             * @param groupId the group ID
17904             * @param classNameId the class name ID
17905             * @param templateId the template ID
17906             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17907             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
17908             * @throws SystemException if a system exception occurred
17909             */
17910            public JournalArticle fetchByG_C_T_First(long groupId, long classNameId,
17911                    String templateId, OrderByComparator orderByComparator)
17912                    throws SystemException {
17913                    List<JournalArticle> list = findByG_C_T(groupId, classNameId,
17914                                    templateId, 0, 1, orderByComparator);
17915    
17916                    if (!list.isEmpty()) {
17917                            return list.get(0);
17918                    }
17919    
17920                    return null;
17921            }
17922    
17923            /**
17924             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
17925             *
17926             * @param groupId the group ID
17927             * @param classNameId the class name ID
17928             * @param templateId the template ID
17929             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17930             * @return the last matching journal article
17931             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
17932             * @throws SystemException if a system exception occurred
17933             */
17934            public JournalArticle findByG_C_T_Last(long groupId, long classNameId,
17935                    String templateId, OrderByComparator orderByComparator)
17936                    throws NoSuchArticleException, SystemException {
17937                    JournalArticle journalArticle = fetchByG_C_T_Last(groupId, classNameId,
17938                                    templateId, orderByComparator);
17939    
17940                    if (journalArticle != null) {
17941                            return journalArticle;
17942                    }
17943    
17944                    StringBundler msg = new StringBundler(8);
17945    
17946                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17947    
17948                    msg.append("groupId=");
17949                    msg.append(groupId);
17950    
17951                    msg.append(", classNameId=");
17952                    msg.append(classNameId);
17953    
17954                    msg.append(", templateId=");
17955                    msg.append(templateId);
17956    
17957                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17958    
17959                    throw new NoSuchArticleException(msg.toString());
17960            }
17961    
17962            /**
17963             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
17964             *
17965             * @param groupId the group ID
17966             * @param classNameId the class name ID
17967             * @param templateId the template ID
17968             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17969             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
17970             * @throws SystemException if a system exception occurred
17971             */
17972            public JournalArticle fetchByG_C_T_Last(long groupId, long classNameId,
17973                    String templateId, OrderByComparator orderByComparator)
17974                    throws SystemException {
17975                    int count = countByG_C_T(groupId, classNameId, templateId);
17976    
17977                    List<JournalArticle> list = findByG_C_T(groupId, classNameId,
17978                                    templateId, count - 1, count, orderByComparator);
17979    
17980                    if (!list.isEmpty()) {
17981                            return list.get(0);
17982                    }
17983    
17984                    return null;
17985            }
17986    
17987            /**
17988             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
17989             *
17990             * @param id the primary key of the current journal article
17991             * @param groupId the group ID
17992             * @param classNameId the class name ID
17993             * @param templateId the template ID
17994             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17995             * @return the previous, current, and next journal article
17996             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
17997             * @throws SystemException if a system exception occurred
17998             */
17999            public JournalArticle[] findByG_C_T_PrevAndNext(long id, long groupId,
18000                    long classNameId, String templateId, OrderByComparator orderByComparator)
18001                    throws NoSuchArticleException, SystemException {
18002                    JournalArticle journalArticle = findByPrimaryKey(id);
18003    
18004                    Session session = null;
18005    
18006                    try {
18007                            session = openSession();
18008    
18009                            JournalArticle[] array = new JournalArticleImpl[3];
18010    
18011                            array[0] = getByG_C_T_PrevAndNext(session, journalArticle, groupId,
18012                                            classNameId, templateId, orderByComparator, true);
18013    
18014                            array[1] = journalArticle;
18015    
18016                            array[2] = getByG_C_T_PrevAndNext(session, journalArticle, groupId,
18017                                            classNameId, templateId, orderByComparator, false);
18018    
18019                            return array;
18020                    }
18021                    catch (Exception e) {
18022                            throw processException(e);
18023                    }
18024                    finally {
18025                            closeSession(session);
18026                    }
18027            }
18028    
18029            protected JournalArticle getByG_C_T_PrevAndNext(Session session,
18030                    JournalArticle journalArticle, long groupId, long classNameId,
18031                    String templateId, OrderByComparator orderByComparator, boolean previous) {
18032                    StringBundler query = null;
18033    
18034                    if (orderByComparator != null) {
18035                            query = new StringBundler(6 +
18036                                            (orderByComparator.getOrderByFields().length * 6));
18037                    }
18038                    else {
18039                            query = new StringBundler(3);
18040                    }
18041    
18042                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
18043    
18044                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
18045    
18046                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
18047    
18048                    if (templateId == null) {
18049                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
18050                    }
18051                    else {
18052                            if (templateId.equals(StringPool.BLANK)) {
18053                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
18054                            }
18055                            else {
18056                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
18057                            }
18058                    }
18059    
18060                    if (orderByComparator != null) {
18061                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
18062    
18063                            if (orderByConditionFields.length > 0) {
18064                                    query.append(WHERE_AND);
18065                            }
18066    
18067                            for (int i = 0; i < orderByConditionFields.length; i++) {
18068                                    query.append(_ORDER_BY_ENTITY_ALIAS);
18069                                    query.append(orderByConditionFields[i]);
18070    
18071                                    if ((i + 1) < orderByConditionFields.length) {
18072                                            if (orderByComparator.isAscending() ^ previous) {
18073                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
18074                                            }
18075                                            else {
18076                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
18077                                            }
18078                                    }
18079                                    else {
18080                                            if (orderByComparator.isAscending() ^ previous) {
18081                                                    query.append(WHERE_GREATER_THAN);
18082                                            }
18083                                            else {
18084                                                    query.append(WHERE_LESSER_THAN);
18085                                            }
18086                                    }
18087                            }
18088    
18089                            query.append(ORDER_BY_CLAUSE);
18090    
18091                            String[] orderByFields = orderByComparator.getOrderByFields();
18092    
18093                            for (int i = 0; i < orderByFields.length; i++) {
18094                                    query.append(_ORDER_BY_ENTITY_ALIAS);
18095                                    query.append(orderByFields[i]);
18096    
18097                                    if ((i + 1) < orderByFields.length) {
18098                                            if (orderByComparator.isAscending() ^ previous) {
18099                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
18100                                            }
18101                                            else {
18102                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
18103                                            }
18104                                    }
18105                                    else {
18106                                            if (orderByComparator.isAscending() ^ previous) {
18107                                                    query.append(ORDER_BY_ASC);
18108                                            }
18109                                            else {
18110                                                    query.append(ORDER_BY_DESC);
18111                                            }
18112                                    }
18113                            }
18114                    }
18115                    else {
18116                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18117                    }
18118    
18119                    String sql = query.toString();
18120    
18121                    Query q = session.createQuery(sql);
18122    
18123                    q.setFirstResult(0);
18124                    q.setMaxResults(2);
18125    
18126                    QueryPos qPos = QueryPos.getInstance(q);
18127    
18128                    qPos.add(groupId);
18129    
18130                    qPos.add(classNameId);
18131    
18132                    if (templateId != null) {
18133                            qPos.add(templateId);
18134                    }
18135    
18136                    if (orderByComparator != null) {
18137                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
18138    
18139                            for (Object value : values) {
18140                                    qPos.add(value);
18141                            }
18142                    }
18143    
18144                    List<JournalArticle> list = q.list();
18145    
18146                    if (list.size() == 2) {
18147                            return list.get(1);
18148                    }
18149                    else {
18150                            return null;
18151                    }
18152            }
18153    
18154            /**
18155             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
18156             *
18157             * @param groupId the group ID
18158             * @param classNameId the class name ID
18159             * @param templateId the template ID
18160             * @return the matching journal articles that the user has permission to view
18161             * @throws SystemException if a system exception occurred
18162             */
18163            public List<JournalArticle> filterFindByG_C_T(long groupId,
18164                    long classNameId, String templateId) throws SystemException {
18165                    return filterFindByG_C_T(groupId, classNameId, templateId,
18166                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
18167            }
18168    
18169            /**
18170             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
18171             *
18172             * <p>
18173             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18174             * </p>
18175             *
18176             * @param groupId the group ID
18177             * @param classNameId the class name ID
18178             * @param templateId the template ID
18179             * @param start the lower bound of the range of journal articles
18180             * @param end the upper bound of the range of journal articles (not inclusive)
18181             * @return the range of matching journal articles that the user has permission to view
18182             * @throws SystemException if a system exception occurred
18183             */
18184            public List<JournalArticle> filterFindByG_C_T(long groupId,
18185                    long classNameId, String templateId, int start, int end)
18186                    throws SystemException {
18187                    return filterFindByG_C_T(groupId, classNameId, templateId, start, end,
18188                            null);
18189            }
18190    
18191            /**
18192             * 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;.
18193             *
18194             * <p>
18195             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18196             * </p>
18197             *
18198             * @param groupId the group ID
18199             * @param classNameId the class name ID
18200             * @param templateId the template ID
18201             * @param start the lower bound of the range of journal articles
18202             * @param end the upper bound of the range of journal articles (not inclusive)
18203             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18204             * @return the ordered range of matching journal articles that the user has permission to view
18205             * @throws SystemException if a system exception occurred
18206             */
18207            public List<JournalArticle> filterFindByG_C_T(long groupId,
18208                    long classNameId, String templateId, int start, int end,
18209                    OrderByComparator orderByComparator) throws SystemException {
18210                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18211                            return findByG_C_T(groupId, classNameId, templateId, start, end,
18212                                    orderByComparator);
18213                    }
18214    
18215                    StringBundler query = null;
18216    
18217                    if (orderByComparator != null) {
18218                            query = new StringBundler(5 +
18219                                            (orderByComparator.getOrderByFields().length * 3));
18220                    }
18221                    else {
18222                            query = new StringBundler(5);
18223                    }
18224    
18225                    if (getDB().isSupportsInlineDistinct()) {
18226                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
18227                    }
18228                    else {
18229                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
18230                    }
18231    
18232                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
18233    
18234                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
18235    
18236                    if (templateId == null) {
18237                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
18238                    }
18239                    else {
18240                            if (templateId.equals(StringPool.BLANK)) {
18241                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
18242                            }
18243                            else {
18244                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
18245                            }
18246                    }
18247    
18248                    if (!getDB().isSupportsInlineDistinct()) {
18249                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
18250                    }
18251    
18252                    if (orderByComparator != null) {
18253                            if (getDB().isSupportsInlineDistinct()) {
18254                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18255                                            orderByComparator);
18256                            }
18257                            else {
18258                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
18259                                            orderByComparator);
18260                            }
18261                    }
18262                    else {
18263                            if (getDB().isSupportsInlineDistinct()) {
18264                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18265                            }
18266                            else {
18267                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
18268                            }
18269                    }
18270    
18271                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18272                                    JournalArticle.class.getName(),
18273                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18274    
18275                    Session session = null;
18276    
18277                    try {
18278                            session = openSession();
18279    
18280                            SQLQuery q = session.createSQLQuery(sql);
18281    
18282                            if (getDB().isSupportsInlineDistinct()) {
18283                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
18284                            }
18285                            else {
18286                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
18287                            }
18288    
18289                            QueryPos qPos = QueryPos.getInstance(q);
18290    
18291                            qPos.add(groupId);
18292    
18293                            qPos.add(classNameId);
18294    
18295                            if (templateId != null) {
18296                                    qPos.add(templateId);
18297                            }
18298    
18299                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
18300                                    end);
18301                    }
18302                    catch (Exception e) {
18303                            throw processException(e);
18304                    }
18305                    finally {
18306                            closeSession(session);
18307                    }
18308            }
18309    
18310            /**
18311             * 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;.
18312             *
18313             * @param id the primary key of the current journal article
18314             * @param groupId the group ID
18315             * @param classNameId the class name ID
18316             * @param templateId the template ID
18317             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18318             * @return the previous, current, and next journal article
18319             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
18320             * @throws SystemException if a system exception occurred
18321             */
18322            public JournalArticle[] filterFindByG_C_T_PrevAndNext(long id,
18323                    long groupId, long classNameId, String templateId,
18324                    OrderByComparator orderByComparator)
18325                    throws NoSuchArticleException, SystemException {
18326                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18327                            return findByG_C_T_PrevAndNext(id, groupId, classNameId,
18328                                    templateId, orderByComparator);
18329                    }
18330    
18331                    JournalArticle journalArticle = findByPrimaryKey(id);
18332    
18333                    Session session = null;
18334    
18335                    try {
18336                            session = openSession();
18337    
18338                            JournalArticle[] array = new JournalArticleImpl[3];
18339    
18340                            array[0] = filterGetByG_C_T_PrevAndNext(session, journalArticle,
18341                                            groupId, classNameId, templateId, orderByComparator, true);
18342    
18343                            array[1] = journalArticle;
18344    
18345                            array[2] = filterGetByG_C_T_PrevAndNext(session, journalArticle,
18346                                            groupId, classNameId, templateId, orderByComparator, false);
18347    
18348                            return array;
18349                    }
18350                    catch (Exception e) {
18351                            throw processException(e);
18352                    }
18353                    finally {
18354                            closeSession(session);
18355                    }
18356            }
18357    
18358            protected JournalArticle filterGetByG_C_T_PrevAndNext(Session session,
18359                    JournalArticle journalArticle, long groupId, long classNameId,
18360                    String templateId, OrderByComparator orderByComparator, boolean previous) {
18361                    StringBundler query = null;
18362    
18363                    if (orderByComparator != null) {
18364                            query = new StringBundler(6 +
18365                                            (orderByComparator.getOrderByFields().length * 6));
18366                    }
18367                    else {
18368                            query = new StringBundler(3);
18369                    }
18370    
18371                    if (getDB().isSupportsInlineDistinct()) {
18372                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
18373                    }
18374                    else {
18375                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
18376                    }
18377    
18378                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
18379    
18380                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
18381    
18382                    if (templateId == null) {
18383                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
18384                    }
18385                    else {
18386                            if (templateId.equals(StringPool.BLANK)) {
18387                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
18388                            }
18389                            else {
18390                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
18391                            }
18392                    }
18393    
18394                    if (!getDB().isSupportsInlineDistinct()) {
18395                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
18396                    }
18397    
18398                    if (orderByComparator != null) {
18399                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
18400    
18401                            if (orderByConditionFields.length > 0) {
18402                                    query.append(WHERE_AND);
18403                            }
18404    
18405                            for (int i = 0; i < orderByConditionFields.length; i++) {
18406                                    if (getDB().isSupportsInlineDistinct()) {
18407                                            query.append(_ORDER_BY_ENTITY_ALIAS);
18408                                    }
18409                                    else {
18410                                            query.append(_ORDER_BY_ENTITY_TABLE);
18411                                    }
18412    
18413                                    query.append(orderByConditionFields[i]);
18414    
18415                                    if ((i + 1) < orderByConditionFields.length) {
18416                                            if (orderByComparator.isAscending() ^ previous) {
18417                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
18418                                            }
18419                                            else {
18420                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
18421                                            }
18422                                    }
18423                                    else {
18424                                            if (orderByComparator.isAscending() ^ previous) {
18425                                                    query.append(WHERE_GREATER_THAN);
18426                                            }
18427                                            else {
18428                                                    query.append(WHERE_LESSER_THAN);
18429                                            }
18430                                    }
18431                            }
18432    
18433                            query.append(ORDER_BY_CLAUSE);
18434    
18435                            String[] orderByFields = orderByComparator.getOrderByFields();
18436    
18437                            for (int i = 0; i < orderByFields.length; i++) {
18438                                    if (getDB().isSupportsInlineDistinct()) {
18439                                            query.append(_ORDER_BY_ENTITY_ALIAS);
18440                                    }
18441                                    else {
18442                                            query.append(_ORDER_BY_ENTITY_TABLE);
18443                                    }
18444    
18445                                    query.append(orderByFields[i]);
18446    
18447                                    if ((i + 1) < orderByFields.length) {
18448                                            if (orderByComparator.isAscending() ^ previous) {
18449                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
18450                                            }
18451                                            else {
18452                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
18453                                            }
18454                                    }
18455                                    else {
18456                                            if (orderByComparator.isAscending() ^ previous) {
18457                                                    query.append(ORDER_BY_ASC);
18458                                            }
18459                                            else {
18460                                                    query.append(ORDER_BY_DESC);
18461                                            }
18462                                    }
18463                            }
18464                    }
18465                    else {
18466                            if (getDB().isSupportsInlineDistinct()) {
18467                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18468                            }
18469                            else {
18470                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
18471                            }
18472                    }
18473    
18474                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18475                                    JournalArticle.class.getName(),
18476                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18477    
18478                    SQLQuery q = session.createSQLQuery(sql);
18479    
18480                    q.setFirstResult(0);
18481                    q.setMaxResults(2);
18482    
18483                    if (getDB().isSupportsInlineDistinct()) {
18484                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
18485                    }
18486                    else {
18487                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
18488                    }
18489    
18490                    QueryPos qPos = QueryPos.getInstance(q);
18491    
18492                    qPos.add(groupId);
18493    
18494                    qPos.add(classNameId);
18495    
18496                    if (templateId != null) {
18497                            qPos.add(templateId);
18498                    }
18499    
18500                    if (orderByComparator != null) {
18501                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
18502    
18503                            for (Object value : values) {
18504                                    qPos.add(value);
18505                            }
18506                    }
18507    
18508                    List<JournalArticle> list = q.list();
18509    
18510                    if (list.size() == 2) {
18511                            return list.get(1);
18512                    }
18513                    else {
18514                            return null;
18515                    }
18516            }
18517    
18518            /**
18519             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63; from the database.
18520             *
18521             * @param groupId the group ID
18522             * @param classNameId the class name ID
18523             * @param templateId the template ID
18524             * @throws SystemException if a system exception occurred
18525             */
18526            public void removeByG_C_T(long groupId, long classNameId, String templateId)
18527                    throws SystemException {
18528                    for (JournalArticle journalArticle : findByG_C_T(groupId, classNameId,
18529                                    templateId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
18530                            remove(journalArticle);
18531                    }
18532            }
18533    
18534            /**
18535             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
18536             *
18537             * @param groupId the group ID
18538             * @param classNameId the class name ID
18539             * @param templateId the template ID
18540             * @return the number of matching journal articles
18541             * @throws SystemException if a system exception occurred
18542             */
18543            public int countByG_C_T(long groupId, long classNameId, String templateId)
18544                    throws SystemException {
18545                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_T;
18546    
18547                    Object[] finderArgs = new Object[] { groupId, classNameId, templateId };
18548    
18549                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
18550                                    this);
18551    
18552                    if (count == null) {
18553                            StringBundler query = new StringBundler(4);
18554    
18555                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
18556    
18557                            query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
18558    
18559                            query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
18560    
18561                            if (templateId == null) {
18562                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
18563                            }
18564                            else {
18565                                    if (templateId.equals(StringPool.BLANK)) {
18566                                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
18567                                    }
18568                                    else {
18569                                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
18570                                    }
18571                            }
18572    
18573                            String sql = query.toString();
18574    
18575                            Session session = null;
18576    
18577                            try {
18578                                    session = openSession();
18579    
18580                                    Query q = session.createQuery(sql);
18581    
18582                                    QueryPos qPos = QueryPos.getInstance(q);
18583    
18584                                    qPos.add(groupId);
18585    
18586                                    qPos.add(classNameId);
18587    
18588                                    if (templateId != null) {
18589                                            qPos.add(templateId);
18590                                    }
18591    
18592                                    count = (Long)q.uniqueResult();
18593    
18594                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
18595                            }
18596                            catch (Exception e) {
18597                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18598    
18599                                    throw processException(e);
18600                            }
18601                            finally {
18602                                    closeSession(session);
18603                            }
18604                    }
18605    
18606                    return count.intValue();
18607            }
18608    
18609            /**
18610             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
18611             *
18612             * @param groupId the group ID
18613             * @param classNameId the class name ID
18614             * @param templateId the template ID
18615             * @return the number of matching journal articles that the user has permission to view
18616             * @throws SystemException if a system exception occurred
18617             */
18618            public int filterCountByG_C_T(long groupId, long classNameId,
18619                    String templateId) throws SystemException {
18620                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18621                            return countByG_C_T(groupId, classNameId, templateId);
18622                    }
18623    
18624                    StringBundler query = new StringBundler(4);
18625    
18626                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
18627    
18628                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
18629    
18630                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
18631    
18632                    if (templateId == null) {
18633                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
18634                    }
18635                    else {
18636                            if (templateId.equals(StringPool.BLANK)) {
18637                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
18638                            }
18639                            else {
18640                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
18641                            }
18642                    }
18643    
18644                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18645                                    JournalArticle.class.getName(),
18646                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18647    
18648                    Session session = null;
18649    
18650                    try {
18651                            session = openSession();
18652    
18653                            SQLQuery q = session.createSQLQuery(sql);
18654    
18655                            q.addScalar(COUNT_COLUMN_NAME,
18656                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
18657    
18658                            QueryPos qPos = QueryPos.getInstance(q);
18659    
18660                            qPos.add(groupId);
18661    
18662                            qPos.add(classNameId);
18663    
18664                            if (templateId != null) {
18665                                    qPos.add(templateId);
18666                            }
18667    
18668                            Long count = (Long)q.uniqueResult();
18669    
18670                            return count.intValue();
18671                    }
18672                    catch (Exception e) {
18673                            throw processException(e);
18674                    }
18675                    finally {
18676                            closeSession(session);
18677                    }
18678            }
18679    
18680            private static final String _FINDER_COLUMN_G_C_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
18681            private static final String _FINDER_COLUMN_G_C_T_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
18682            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
18683            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
18684            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = ?)";
18685            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18686                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
18687                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
18688                            "findByG_C_L",
18689                            new String[] {
18690                                    Long.class.getName(), Long.class.getName(),
18691                                    String.class.getName(),
18692                                    
18693                            Integer.class.getName(), Integer.class.getName(),
18694                                    OrderByComparator.class.getName()
18695                            });
18696            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18697                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
18698                            JournalArticleImpl.class,
18699                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_L",
18700                            new String[] {
18701                                    Long.class.getName(), Long.class.getName(),
18702                                    String.class.getName()
18703                            },
18704                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
18705                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
18706                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK |
18707                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
18708                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
18709            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18710                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
18711                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_L",
18712                            new String[] {
18713                                    Long.class.getName(), Long.class.getName(),
18714                                    String.class.getName()
18715                            });
18716    
18717            /**
18718             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
18719             *
18720             * @param groupId the group ID
18721             * @param classNameId the class name ID
18722             * @param layoutUuid the layout uuid
18723             * @return the matching journal articles
18724             * @throws SystemException if a system exception occurred
18725             */
18726            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
18727                    String layoutUuid) throws SystemException {
18728                    return findByG_C_L(groupId, classNameId, layoutUuid, QueryUtil.ALL_POS,
18729                            QueryUtil.ALL_POS, null);
18730            }
18731    
18732            /**
18733             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
18734             *
18735             * <p>
18736             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18737             * </p>
18738             *
18739             * @param groupId the group ID
18740             * @param classNameId the class name ID
18741             * @param layoutUuid the layout uuid
18742             * @param start the lower bound of the range of journal articles
18743             * @param end the upper bound of the range of journal articles (not inclusive)
18744             * @return the range of matching journal articles
18745             * @throws SystemException if a system exception occurred
18746             */
18747            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
18748                    String layoutUuid, int start, int end) throws SystemException {
18749                    return findByG_C_L(groupId, classNameId, layoutUuid, start, end, null);
18750            }
18751    
18752            /**
18753             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
18754             *
18755             * <p>
18756             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18757             * </p>
18758             *
18759             * @param groupId the group ID
18760             * @param classNameId the class name ID
18761             * @param layoutUuid the layout uuid
18762             * @param start the lower bound of the range of journal articles
18763             * @param end the upper bound of the range of journal articles (not inclusive)
18764             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18765             * @return the ordered range of matching journal articles
18766             * @throws SystemException if a system exception occurred
18767             */
18768            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
18769                    String layoutUuid, int start, int end,
18770                    OrderByComparator orderByComparator) throws SystemException {
18771                    boolean pagination = true;
18772                    FinderPath finderPath = null;
18773                    Object[] finderArgs = null;
18774    
18775                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
18776                                    (orderByComparator == null)) {
18777                            pagination = false;
18778                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L;
18779                            finderArgs = new Object[] { groupId, classNameId, layoutUuid };
18780                    }
18781                    else {
18782                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L;
18783                            finderArgs = new Object[] {
18784                                            groupId, classNameId, layoutUuid,
18785                                            
18786                                            start, end, orderByComparator
18787                                    };
18788                    }
18789    
18790                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
18791                                    finderArgs, this);
18792    
18793                    if ((list != null) && !list.isEmpty()) {
18794                            for (JournalArticle journalArticle : list) {
18795                                    if ((groupId != journalArticle.getGroupId()) ||
18796                                                    (classNameId != journalArticle.getClassNameId()) ||
18797                                                    !Validator.equals(layoutUuid,
18798                                                            journalArticle.getLayoutUuid())) {
18799                                            list = null;
18800    
18801                                            break;
18802                                    }
18803                            }
18804                    }
18805    
18806                    if (list == null) {
18807                            StringBundler query = null;
18808    
18809                            if (orderByComparator != null) {
18810                                    query = new StringBundler(5 +
18811                                                    (orderByComparator.getOrderByFields().length * 3));
18812                            }
18813                            else {
18814                                    query = new StringBundler(5);
18815                            }
18816    
18817                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
18818    
18819                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
18820    
18821                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
18822    
18823                            if (layoutUuid == null) {
18824                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
18825                            }
18826                            else {
18827                                    if (layoutUuid.equals(StringPool.BLANK)) {
18828                                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
18829                                    }
18830                                    else {
18831                                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
18832                                    }
18833                            }
18834    
18835                            if (orderByComparator != null) {
18836                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18837                                            orderByComparator);
18838                            }
18839                            else
18840                             if (pagination) {
18841                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18842                            }
18843    
18844                            String sql = query.toString();
18845    
18846                            Session session = null;
18847    
18848                            try {
18849                                    session = openSession();
18850    
18851                                    Query q = session.createQuery(sql);
18852    
18853                                    QueryPos qPos = QueryPos.getInstance(q);
18854    
18855                                    qPos.add(groupId);
18856    
18857                                    qPos.add(classNameId);
18858    
18859                                    if (layoutUuid != null) {
18860                                            qPos.add(layoutUuid);
18861                                    }
18862    
18863                                    if (!pagination) {
18864                                            list = (List<JournalArticle>)QueryUtil.list(q,
18865                                                            getDialect(), start, end, false);
18866    
18867                                            Collections.sort(list);
18868    
18869                                            list = new UnmodifiableList<JournalArticle>(list);
18870                                    }
18871                                    else {
18872                                            list = (List<JournalArticle>)QueryUtil.list(q,
18873                                                            getDialect(), start, end);
18874                                    }
18875    
18876                                    cacheResult(list);
18877    
18878                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
18879                            }
18880                            catch (Exception e) {
18881                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18882    
18883                                    throw processException(e);
18884                            }
18885                            finally {
18886                                    closeSession(session);
18887                            }
18888                    }
18889    
18890                    return list;
18891            }
18892    
18893            /**
18894             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
18895             *
18896             * @param groupId the group ID
18897             * @param classNameId the class name ID
18898             * @param layoutUuid the layout uuid
18899             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18900             * @return the first matching journal article
18901             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
18902             * @throws SystemException if a system exception occurred
18903             */
18904            public JournalArticle findByG_C_L_First(long groupId, long classNameId,
18905                    String layoutUuid, OrderByComparator orderByComparator)
18906                    throws NoSuchArticleException, SystemException {
18907                    JournalArticle journalArticle = fetchByG_C_L_First(groupId,
18908                                    classNameId, layoutUuid, orderByComparator);
18909    
18910                    if (journalArticle != null) {
18911                            return journalArticle;
18912                    }
18913    
18914                    StringBundler msg = new StringBundler(8);
18915    
18916                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
18917    
18918                    msg.append("groupId=");
18919                    msg.append(groupId);
18920    
18921                    msg.append(", classNameId=");
18922                    msg.append(classNameId);
18923    
18924                    msg.append(", layoutUuid=");
18925                    msg.append(layoutUuid);
18926    
18927                    msg.append(StringPool.CLOSE_CURLY_BRACE);
18928    
18929                    throw new NoSuchArticleException(msg.toString());
18930            }
18931    
18932            /**
18933             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
18934             *
18935             * @param groupId the group ID
18936             * @param classNameId the class name ID
18937             * @param layoutUuid the layout uuid
18938             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18939             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
18940             * @throws SystemException if a system exception occurred
18941             */
18942            public JournalArticle fetchByG_C_L_First(long groupId, long classNameId,
18943                    String layoutUuid, OrderByComparator orderByComparator)
18944                    throws SystemException {
18945                    List<JournalArticle> list = findByG_C_L(groupId, classNameId,
18946                                    layoutUuid, 0, 1, orderByComparator);
18947    
18948                    if (!list.isEmpty()) {
18949                            return list.get(0);
18950                    }
18951    
18952                    return null;
18953            }
18954    
18955            /**
18956             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
18957             *
18958             * @param groupId the group ID
18959             * @param classNameId the class name ID
18960             * @param layoutUuid the layout uuid
18961             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18962             * @return the last matching journal article
18963             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
18964             * @throws SystemException if a system exception occurred
18965             */
18966            public JournalArticle findByG_C_L_Last(long groupId, long classNameId,
18967                    String layoutUuid, OrderByComparator orderByComparator)
18968                    throws NoSuchArticleException, SystemException {
18969                    JournalArticle journalArticle = fetchByG_C_L_Last(groupId, classNameId,
18970                                    layoutUuid, orderByComparator);
18971    
18972                    if (journalArticle != null) {
18973                            return journalArticle;
18974                    }
18975    
18976                    StringBundler msg = new StringBundler(8);
18977    
18978                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
18979    
18980                    msg.append("groupId=");
18981                    msg.append(groupId);
18982    
18983                    msg.append(", classNameId=");
18984                    msg.append(classNameId);
18985    
18986                    msg.append(", layoutUuid=");
18987                    msg.append(layoutUuid);
18988    
18989                    msg.append(StringPool.CLOSE_CURLY_BRACE);
18990    
18991                    throw new NoSuchArticleException(msg.toString());
18992            }
18993    
18994            /**
18995             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
18996             *
18997             * @param groupId the group ID
18998             * @param classNameId the class name ID
18999             * @param layoutUuid the layout uuid
19000             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19001             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
19002             * @throws SystemException if a system exception occurred
19003             */
19004            public JournalArticle fetchByG_C_L_Last(long groupId, long classNameId,
19005                    String layoutUuid, OrderByComparator orderByComparator)
19006                    throws SystemException {
19007                    int count = countByG_C_L(groupId, classNameId, layoutUuid);
19008    
19009                    List<JournalArticle> list = findByG_C_L(groupId, classNameId,
19010                                    layoutUuid, count - 1, count, orderByComparator);
19011    
19012                    if (!list.isEmpty()) {
19013                            return list.get(0);
19014                    }
19015    
19016                    return null;
19017            }
19018    
19019            /**
19020             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
19021             *
19022             * @param id the primary key of the current journal article
19023             * @param groupId the group ID
19024             * @param classNameId the class name ID
19025             * @param layoutUuid the layout uuid
19026             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19027             * @return the previous, current, and next journal article
19028             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
19029             * @throws SystemException if a system exception occurred
19030             */
19031            public JournalArticle[] findByG_C_L_PrevAndNext(long id, long groupId,
19032                    long classNameId, String layoutUuid, OrderByComparator orderByComparator)
19033                    throws NoSuchArticleException, SystemException {
19034                    JournalArticle journalArticle = findByPrimaryKey(id);
19035    
19036                    Session session = null;
19037    
19038                    try {
19039                            session = openSession();
19040    
19041                            JournalArticle[] array = new JournalArticleImpl[3];
19042    
19043                            array[0] = getByG_C_L_PrevAndNext(session, journalArticle, groupId,
19044                                            classNameId, layoutUuid, orderByComparator, true);
19045    
19046                            array[1] = journalArticle;
19047    
19048                            array[2] = getByG_C_L_PrevAndNext(session, journalArticle, groupId,
19049                                            classNameId, layoutUuid, orderByComparator, false);
19050    
19051                            return array;
19052                    }
19053                    catch (Exception e) {
19054                            throw processException(e);
19055                    }
19056                    finally {
19057                            closeSession(session);
19058                    }
19059            }
19060    
19061            protected JournalArticle getByG_C_L_PrevAndNext(Session session,
19062                    JournalArticle journalArticle, long groupId, long classNameId,
19063                    String layoutUuid, OrderByComparator orderByComparator, boolean previous) {
19064                    StringBundler query = null;
19065    
19066                    if (orderByComparator != null) {
19067                            query = new StringBundler(6 +
19068                                            (orderByComparator.getOrderByFields().length * 6));
19069                    }
19070                    else {
19071                            query = new StringBundler(3);
19072                    }
19073    
19074                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
19075    
19076                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
19077    
19078                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
19079    
19080                    if (layoutUuid == null) {
19081                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
19082                    }
19083                    else {
19084                            if (layoutUuid.equals(StringPool.BLANK)) {
19085                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
19086                            }
19087                            else {
19088                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
19089                            }
19090                    }
19091    
19092                    if (orderByComparator != null) {
19093                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
19094    
19095                            if (orderByConditionFields.length > 0) {
19096                                    query.append(WHERE_AND);
19097                            }
19098    
19099                            for (int i = 0; i < orderByConditionFields.length; i++) {
19100                                    query.append(_ORDER_BY_ENTITY_ALIAS);
19101                                    query.append(orderByConditionFields[i]);
19102    
19103                                    if ((i + 1) < orderByConditionFields.length) {
19104                                            if (orderByComparator.isAscending() ^ previous) {
19105                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
19106                                            }
19107                                            else {
19108                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
19109                                            }
19110                                    }
19111                                    else {
19112                                            if (orderByComparator.isAscending() ^ previous) {
19113                                                    query.append(WHERE_GREATER_THAN);
19114                                            }
19115                                            else {
19116                                                    query.append(WHERE_LESSER_THAN);
19117                                            }
19118                                    }
19119                            }
19120    
19121                            query.append(ORDER_BY_CLAUSE);
19122    
19123                            String[] orderByFields = orderByComparator.getOrderByFields();
19124    
19125                            for (int i = 0; i < orderByFields.length; i++) {
19126                                    query.append(_ORDER_BY_ENTITY_ALIAS);
19127                                    query.append(orderByFields[i]);
19128    
19129                                    if ((i + 1) < orderByFields.length) {
19130                                            if (orderByComparator.isAscending() ^ previous) {
19131                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
19132                                            }
19133                                            else {
19134                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
19135                                            }
19136                                    }
19137                                    else {
19138                                            if (orderByComparator.isAscending() ^ previous) {
19139                                                    query.append(ORDER_BY_ASC);
19140                                            }
19141                                            else {
19142                                                    query.append(ORDER_BY_DESC);
19143                                            }
19144                                    }
19145                            }
19146                    }
19147                    else {
19148                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19149                    }
19150    
19151                    String sql = query.toString();
19152    
19153                    Query q = session.createQuery(sql);
19154    
19155                    q.setFirstResult(0);
19156                    q.setMaxResults(2);
19157    
19158                    QueryPos qPos = QueryPos.getInstance(q);
19159    
19160                    qPos.add(groupId);
19161    
19162                    qPos.add(classNameId);
19163    
19164                    if (layoutUuid != null) {
19165                            qPos.add(layoutUuid);
19166                    }
19167    
19168                    if (orderByComparator != null) {
19169                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
19170    
19171                            for (Object value : values) {
19172                                    qPos.add(value);
19173                            }
19174                    }
19175    
19176                    List<JournalArticle> list = q.list();
19177    
19178                    if (list.size() == 2) {
19179                            return list.get(1);
19180                    }
19181                    else {
19182                            return null;
19183                    }
19184            }
19185    
19186            /**
19187             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
19188             *
19189             * @param groupId the group ID
19190             * @param classNameId the class name ID
19191             * @param layoutUuid the layout uuid
19192             * @return the matching journal articles that the user has permission to view
19193             * @throws SystemException if a system exception occurred
19194             */
19195            public List<JournalArticle> filterFindByG_C_L(long groupId,
19196                    long classNameId, String layoutUuid) throws SystemException {
19197                    return filterFindByG_C_L(groupId, classNameId, layoutUuid,
19198                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
19199            }
19200    
19201            /**
19202             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
19203             *
19204             * <p>
19205             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19206             * </p>
19207             *
19208             * @param groupId the group ID
19209             * @param classNameId the class name ID
19210             * @param layoutUuid the layout uuid
19211             * @param start the lower bound of the range of journal articles
19212             * @param end the upper bound of the range of journal articles (not inclusive)
19213             * @return the range of matching journal articles that the user has permission to view
19214             * @throws SystemException if a system exception occurred
19215             */
19216            public List<JournalArticle> filterFindByG_C_L(long groupId,
19217                    long classNameId, String layoutUuid, int start, int end)
19218                    throws SystemException {
19219                    return filterFindByG_C_L(groupId, classNameId, layoutUuid, start, end,
19220                            null);
19221            }
19222    
19223            /**
19224             * 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;.
19225             *
19226             * <p>
19227             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19228             * </p>
19229             *
19230             * @param groupId the group ID
19231             * @param classNameId the class name ID
19232             * @param layoutUuid the layout uuid
19233             * @param start the lower bound of the range of journal articles
19234             * @param end the upper bound of the range of journal articles (not inclusive)
19235             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19236             * @return the ordered range of matching journal articles that the user has permission to view
19237             * @throws SystemException if a system exception occurred
19238             */
19239            public List<JournalArticle> filterFindByG_C_L(long groupId,
19240                    long classNameId, String layoutUuid, int start, int end,
19241                    OrderByComparator orderByComparator) throws SystemException {
19242                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19243                            return findByG_C_L(groupId, classNameId, layoutUuid, start, end,
19244                                    orderByComparator);
19245                    }
19246    
19247                    StringBundler query = null;
19248    
19249                    if (orderByComparator != null) {
19250                            query = new StringBundler(5 +
19251                                            (orderByComparator.getOrderByFields().length * 3));
19252                    }
19253                    else {
19254                            query = new StringBundler(5);
19255                    }
19256    
19257                    if (getDB().isSupportsInlineDistinct()) {
19258                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
19259                    }
19260                    else {
19261                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
19262                    }
19263    
19264                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
19265    
19266                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
19267    
19268                    if (layoutUuid == null) {
19269                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
19270                    }
19271                    else {
19272                            if (layoutUuid.equals(StringPool.BLANK)) {
19273                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
19274                            }
19275                            else {
19276                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
19277                            }
19278                    }
19279    
19280                    if (!getDB().isSupportsInlineDistinct()) {
19281                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
19282                    }
19283    
19284                    if (orderByComparator != null) {
19285                            if (getDB().isSupportsInlineDistinct()) {
19286                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
19287                                            orderByComparator);
19288                            }
19289                            else {
19290                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
19291                                            orderByComparator);
19292                            }
19293                    }
19294                    else {
19295                            if (getDB().isSupportsInlineDistinct()) {
19296                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19297                            }
19298                            else {
19299                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
19300                            }
19301                    }
19302    
19303                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19304                                    JournalArticle.class.getName(),
19305                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19306    
19307                    Session session = null;
19308    
19309                    try {
19310                            session = openSession();
19311    
19312                            SQLQuery q = session.createSQLQuery(sql);
19313    
19314                            if (getDB().isSupportsInlineDistinct()) {
19315                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
19316                            }
19317                            else {
19318                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
19319                            }
19320    
19321                            QueryPos qPos = QueryPos.getInstance(q);
19322    
19323                            qPos.add(groupId);
19324    
19325                            qPos.add(classNameId);
19326    
19327                            if (layoutUuid != null) {
19328                                    qPos.add(layoutUuid);
19329                            }
19330    
19331                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
19332                                    end);
19333                    }
19334                    catch (Exception e) {
19335                            throw processException(e);
19336                    }
19337                    finally {
19338                            closeSession(session);
19339                    }
19340            }
19341    
19342            /**
19343             * 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;.
19344             *
19345             * @param id the primary key of the current journal article
19346             * @param groupId the group ID
19347             * @param classNameId the class name ID
19348             * @param layoutUuid the layout uuid
19349             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19350             * @return the previous, current, and next journal article
19351             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
19352             * @throws SystemException if a system exception occurred
19353             */
19354            public JournalArticle[] filterFindByG_C_L_PrevAndNext(long id,
19355                    long groupId, long classNameId, String layoutUuid,
19356                    OrderByComparator orderByComparator)
19357                    throws NoSuchArticleException, SystemException {
19358                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19359                            return findByG_C_L_PrevAndNext(id, groupId, classNameId,
19360                                    layoutUuid, orderByComparator);
19361                    }
19362    
19363                    JournalArticle journalArticle = findByPrimaryKey(id);
19364    
19365                    Session session = null;
19366    
19367                    try {
19368                            session = openSession();
19369    
19370                            JournalArticle[] array = new JournalArticleImpl[3];
19371    
19372                            array[0] = filterGetByG_C_L_PrevAndNext(session, journalArticle,
19373                                            groupId, classNameId, layoutUuid, orderByComparator, true);
19374    
19375                            array[1] = journalArticle;
19376    
19377                            array[2] = filterGetByG_C_L_PrevAndNext(session, journalArticle,
19378                                            groupId, classNameId, layoutUuid, orderByComparator, false);
19379    
19380                            return array;
19381                    }
19382                    catch (Exception e) {
19383                            throw processException(e);
19384                    }
19385                    finally {
19386                            closeSession(session);
19387                    }
19388            }
19389    
19390            protected JournalArticle filterGetByG_C_L_PrevAndNext(Session session,
19391                    JournalArticle journalArticle, long groupId, long classNameId,
19392                    String layoutUuid, OrderByComparator orderByComparator, boolean previous) {
19393                    StringBundler query = null;
19394    
19395                    if (orderByComparator != null) {
19396                            query = new StringBundler(6 +
19397                                            (orderByComparator.getOrderByFields().length * 6));
19398                    }
19399                    else {
19400                            query = new StringBundler(3);
19401                    }
19402    
19403                    if (getDB().isSupportsInlineDistinct()) {
19404                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
19405                    }
19406                    else {
19407                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
19408                    }
19409    
19410                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
19411    
19412                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
19413    
19414                    if (layoutUuid == null) {
19415                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
19416                    }
19417                    else {
19418                            if (layoutUuid.equals(StringPool.BLANK)) {
19419                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
19420                            }
19421                            else {
19422                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
19423                            }
19424                    }
19425    
19426                    if (!getDB().isSupportsInlineDistinct()) {
19427                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
19428                    }
19429    
19430                    if (orderByComparator != null) {
19431                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
19432    
19433                            if (orderByConditionFields.length > 0) {
19434                                    query.append(WHERE_AND);
19435                            }
19436    
19437                            for (int i = 0; i < orderByConditionFields.length; i++) {
19438                                    if (getDB().isSupportsInlineDistinct()) {
19439                                            query.append(_ORDER_BY_ENTITY_ALIAS);
19440                                    }
19441                                    else {
19442                                            query.append(_ORDER_BY_ENTITY_TABLE);
19443                                    }
19444    
19445                                    query.append(orderByConditionFields[i]);
19446    
19447                                    if ((i + 1) < orderByConditionFields.length) {
19448                                            if (orderByComparator.isAscending() ^ previous) {
19449                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
19450                                            }
19451                                            else {
19452                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
19453                                            }
19454                                    }
19455                                    else {
19456                                            if (orderByComparator.isAscending() ^ previous) {
19457                                                    query.append(WHERE_GREATER_THAN);
19458                                            }
19459                                            else {
19460                                                    query.append(WHERE_LESSER_THAN);
19461                                            }
19462                                    }
19463                            }
19464    
19465                            query.append(ORDER_BY_CLAUSE);
19466    
19467                            String[] orderByFields = orderByComparator.getOrderByFields();
19468    
19469                            for (int i = 0; i < orderByFields.length; i++) {
19470                                    if (getDB().isSupportsInlineDistinct()) {
19471                                            query.append(_ORDER_BY_ENTITY_ALIAS);
19472                                    }
19473                                    else {
19474                                            query.append(_ORDER_BY_ENTITY_TABLE);
19475                                    }
19476    
19477                                    query.append(orderByFields[i]);
19478    
19479                                    if ((i + 1) < orderByFields.length) {
19480                                            if (orderByComparator.isAscending() ^ previous) {
19481                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
19482                                            }
19483                                            else {
19484                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
19485                                            }
19486                                    }
19487                                    else {
19488                                            if (orderByComparator.isAscending() ^ previous) {
19489                                                    query.append(ORDER_BY_ASC);
19490                                            }
19491                                            else {
19492                                                    query.append(ORDER_BY_DESC);
19493                                            }
19494                                    }
19495                            }
19496                    }
19497                    else {
19498                            if (getDB().isSupportsInlineDistinct()) {
19499                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19500                            }
19501                            else {
19502                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
19503                            }
19504                    }
19505    
19506                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19507                                    JournalArticle.class.getName(),
19508                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19509    
19510                    SQLQuery q = session.createSQLQuery(sql);
19511    
19512                    q.setFirstResult(0);
19513                    q.setMaxResults(2);
19514    
19515                    if (getDB().isSupportsInlineDistinct()) {
19516                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
19517                    }
19518                    else {
19519                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
19520                    }
19521    
19522                    QueryPos qPos = QueryPos.getInstance(q);
19523    
19524                    qPos.add(groupId);
19525    
19526                    qPos.add(classNameId);
19527    
19528                    if (layoutUuid != null) {
19529                            qPos.add(layoutUuid);
19530                    }
19531    
19532                    if (orderByComparator != null) {
19533                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
19534    
19535                            for (Object value : values) {
19536                                    qPos.add(value);
19537                            }
19538                    }
19539    
19540                    List<JournalArticle> list = q.list();
19541    
19542                    if (list.size() == 2) {
19543                            return list.get(1);
19544                    }
19545                    else {
19546                            return null;
19547                    }
19548            }
19549    
19550            /**
19551             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63; from the database.
19552             *
19553             * @param groupId the group ID
19554             * @param classNameId the class name ID
19555             * @param layoutUuid the layout uuid
19556             * @throws SystemException if a system exception occurred
19557             */
19558            public void removeByG_C_L(long groupId, long classNameId, String layoutUuid)
19559                    throws SystemException {
19560                    for (JournalArticle journalArticle : findByG_C_L(groupId, classNameId,
19561                                    layoutUuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
19562                            remove(journalArticle);
19563                    }
19564            }
19565    
19566            /**
19567             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
19568             *
19569             * @param groupId the group ID
19570             * @param classNameId the class name ID
19571             * @param layoutUuid the layout uuid
19572             * @return the number of matching journal articles
19573             * @throws SystemException if a system exception occurred
19574             */
19575            public int countByG_C_L(long groupId, long classNameId, String layoutUuid)
19576                    throws SystemException {
19577                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_L;
19578    
19579                    Object[] finderArgs = new Object[] { groupId, classNameId, layoutUuid };
19580    
19581                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
19582                                    this);
19583    
19584                    if (count == null) {
19585                            StringBundler query = new StringBundler(4);
19586    
19587                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
19588    
19589                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
19590    
19591                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
19592    
19593                            if (layoutUuid == null) {
19594                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
19595                            }
19596                            else {
19597                                    if (layoutUuid.equals(StringPool.BLANK)) {
19598                                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
19599                                    }
19600                                    else {
19601                                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
19602                                    }
19603                            }
19604    
19605                            String sql = query.toString();
19606    
19607                            Session session = null;
19608    
19609                            try {
19610                                    session = openSession();
19611    
19612                                    Query q = session.createQuery(sql);
19613    
19614                                    QueryPos qPos = QueryPos.getInstance(q);
19615    
19616                                    qPos.add(groupId);
19617    
19618                                    qPos.add(classNameId);
19619    
19620                                    if (layoutUuid != null) {
19621                                            qPos.add(layoutUuid);
19622                                    }
19623    
19624                                    count = (Long)q.uniqueResult();
19625    
19626                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
19627                            }
19628                            catch (Exception e) {
19629                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
19630    
19631                                    throw processException(e);
19632                            }
19633                            finally {
19634                                    closeSession(session);
19635                            }
19636                    }
19637    
19638                    return count.intValue();
19639            }
19640    
19641            /**
19642             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
19643             *
19644             * @param groupId the group ID
19645             * @param classNameId the class name ID
19646             * @param layoutUuid the layout uuid
19647             * @return the number of matching journal articles that the user has permission to view
19648             * @throws SystemException if a system exception occurred
19649             */
19650            public int filterCountByG_C_L(long groupId, long classNameId,
19651                    String layoutUuid) throws SystemException {
19652                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19653                            return countByG_C_L(groupId, classNameId, layoutUuid);
19654                    }
19655    
19656                    StringBundler query = new StringBundler(4);
19657    
19658                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
19659    
19660                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
19661    
19662                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
19663    
19664                    if (layoutUuid == null) {
19665                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
19666                    }
19667                    else {
19668                            if (layoutUuid.equals(StringPool.BLANK)) {
19669                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
19670                            }
19671                            else {
19672                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
19673                            }
19674                    }
19675    
19676                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19677                                    JournalArticle.class.getName(),
19678                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19679    
19680                    Session session = null;
19681    
19682                    try {
19683                            session = openSession();
19684    
19685                            SQLQuery q = session.createSQLQuery(sql);
19686    
19687                            q.addScalar(COUNT_COLUMN_NAME,
19688                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
19689    
19690                            QueryPos qPos = QueryPos.getInstance(q);
19691    
19692                            qPos.add(groupId);
19693    
19694                            qPos.add(classNameId);
19695    
19696                            if (layoutUuid != null) {
19697                                    qPos.add(layoutUuid);
19698                            }
19699    
19700                            Long count = (Long)q.uniqueResult();
19701    
19702                            return count.intValue();
19703                    }
19704                    catch (Exception e) {
19705                            throw processException(e);
19706                    }
19707                    finally {
19708                            closeSession(session);
19709                    }
19710            }
19711    
19712            private static final String _FINDER_COLUMN_G_C_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
19713            private static final String _FINDER_COLUMN_G_C_L_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
19714            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
19715            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
19716            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = ?)";
19717            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19718                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
19719                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
19720                            "findByG_U_C",
19721                            new String[] {
19722                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
19723                                    
19724                            Integer.class.getName(), Integer.class.getName(),
19725                                    OrderByComparator.class.getName()
19726                            });
19727            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19728                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
19729                            JournalArticleImpl.class,
19730                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_C",
19731                            new String[] {
19732                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
19733                            },
19734                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
19735                            JournalArticleModelImpl.USERID_COLUMN_BITMASK |
19736                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
19737                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
19738                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
19739            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19740                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
19741                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_C",
19742                            new String[] {
19743                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
19744                            });
19745    
19746            /**
19747             * Returns all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
19748             *
19749             * @param groupId the group ID
19750             * @param userId the user ID
19751             * @param classNameId the class name ID
19752             * @return the matching journal articles
19753             * @throws SystemException if a system exception occurred
19754             */
19755            public List<JournalArticle> findByG_U_C(long groupId, long userId,
19756                    long classNameId) throws SystemException {
19757                    return findByG_U_C(groupId, userId, classNameId, QueryUtil.ALL_POS,
19758                            QueryUtil.ALL_POS, null);
19759            }
19760    
19761            /**
19762             * Returns a range of all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
19763             *
19764             * <p>
19765             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19766             * </p>
19767             *
19768             * @param groupId the group ID
19769             * @param userId the user ID
19770             * @param classNameId the class name ID
19771             * @param start the lower bound of the range of journal articles
19772             * @param end the upper bound of the range of journal articles (not inclusive)
19773             * @return the range of matching journal articles
19774             * @throws SystemException if a system exception occurred
19775             */
19776            public List<JournalArticle> findByG_U_C(long groupId, long userId,
19777                    long classNameId, int start, int end) throws SystemException {
19778                    return findByG_U_C(groupId, userId, classNameId, start, end, null);
19779            }
19780    
19781            /**
19782             * Returns an ordered range of all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
19783             *
19784             * <p>
19785             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19786             * </p>
19787             *
19788             * @param groupId the group ID
19789             * @param userId the user ID
19790             * @param classNameId the class name ID
19791             * @param start the lower bound of the range of journal articles
19792             * @param end the upper bound of the range of journal articles (not inclusive)
19793             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19794             * @return the ordered range of matching journal articles
19795             * @throws SystemException if a system exception occurred
19796             */
19797            public List<JournalArticle> findByG_U_C(long groupId, long userId,
19798                    long classNameId, int start, int end,
19799                    OrderByComparator orderByComparator) throws SystemException {
19800                    boolean pagination = true;
19801                    FinderPath finderPath = null;
19802                    Object[] finderArgs = null;
19803    
19804                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
19805                                    (orderByComparator == null)) {
19806                            pagination = false;
19807                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C;
19808                            finderArgs = new Object[] { groupId, userId, classNameId };
19809                    }
19810                    else {
19811                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_C;
19812                            finderArgs = new Object[] {
19813                                            groupId, userId, classNameId,
19814                                            
19815                                            start, end, orderByComparator
19816                                    };
19817                    }
19818    
19819                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
19820                                    finderArgs, this);
19821    
19822                    if ((list != null) && !list.isEmpty()) {
19823                            for (JournalArticle journalArticle : list) {
19824                                    if ((groupId != journalArticle.getGroupId()) ||
19825                                                    (userId != journalArticle.getUserId()) ||
19826                                                    (classNameId != journalArticle.getClassNameId())) {
19827                                            list = null;
19828    
19829                                            break;
19830                                    }
19831                            }
19832                    }
19833    
19834                    if (list == null) {
19835                            StringBundler query = null;
19836    
19837                            if (orderByComparator != null) {
19838                                    query = new StringBundler(5 +
19839                                                    (orderByComparator.getOrderByFields().length * 3));
19840                            }
19841                            else {
19842                                    query = new StringBundler(5);
19843                            }
19844    
19845                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
19846    
19847                            query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
19848    
19849                            query.append(_FINDER_COLUMN_G_U_C_USERID_2);
19850    
19851                            query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
19852    
19853                            if (orderByComparator != null) {
19854                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
19855                                            orderByComparator);
19856                            }
19857                            else
19858                             if (pagination) {
19859                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19860                            }
19861    
19862                            String sql = query.toString();
19863    
19864                            Session session = null;
19865    
19866                            try {
19867                                    session = openSession();
19868    
19869                                    Query q = session.createQuery(sql);
19870    
19871                                    QueryPos qPos = QueryPos.getInstance(q);
19872    
19873                                    qPos.add(groupId);
19874    
19875                                    qPos.add(userId);
19876    
19877                                    qPos.add(classNameId);
19878    
19879                                    if (!pagination) {
19880                                            list = (List<JournalArticle>)QueryUtil.list(q,
19881                                                            getDialect(), start, end, false);
19882    
19883                                            Collections.sort(list);
19884    
19885                                            list = new UnmodifiableList<JournalArticle>(list);
19886                                    }
19887                                    else {
19888                                            list = (List<JournalArticle>)QueryUtil.list(q,
19889                                                            getDialect(), start, end);
19890                                    }
19891    
19892                                    cacheResult(list);
19893    
19894                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
19895                            }
19896                            catch (Exception e) {
19897                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
19898    
19899                                    throw processException(e);
19900                            }
19901                            finally {
19902                                    closeSession(session);
19903                            }
19904                    }
19905    
19906                    return list;
19907            }
19908    
19909            /**
19910             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
19911             *
19912             * @param groupId the group ID
19913             * @param userId the user ID
19914             * @param classNameId the class name ID
19915             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19916             * @return the first matching journal article
19917             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
19918             * @throws SystemException if a system exception occurred
19919             */
19920            public JournalArticle findByG_U_C_First(long groupId, long userId,
19921                    long classNameId, OrderByComparator orderByComparator)
19922                    throws NoSuchArticleException, SystemException {
19923                    JournalArticle journalArticle = fetchByG_U_C_First(groupId, userId,
19924                                    classNameId, orderByComparator);
19925    
19926                    if (journalArticle != null) {
19927                            return journalArticle;
19928                    }
19929    
19930                    StringBundler msg = new StringBundler(8);
19931    
19932                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
19933    
19934                    msg.append("groupId=");
19935                    msg.append(groupId);
19936    
19937                    msg.append(", userId=");
19938                    msg.append(userId);
19939    
19940                    msg.append(", classNameId=");
19941                    msg.append(classNameId);
19942    
19943                    msg.append(StringPool.CLOSE_CURLY_BRACE);
19944    
19945                    throw new NoSuchArticleException(msg.toString());
19946            }
19947    
19948            /**
19949             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
19950             *
19951             * @param groupId the group ID
19952             * @param userId the user ID
19953             * @param classNameId the class name ID
19954             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19955             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
19956             * @throws SystemException if a system exception occurred
19957             */
19958            public JournalArticle fetchByG_U_C_First(long groupId, long userId,
19959                    long classNameId, OrderByComparator orderByComparator)
19960                    throws SystemException {
19961                    List<JournalArticle> list = findByG_U_C(groupId, userId, classNameId,
19962                                    0, 1, orderByComparator);
19963    
19964                    if (!list.isEmpty()) {
19965                            return list.get(0);
19966                    }
19967    
19968                    return null;
19969            }
19970    
19971            /**
19972             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
19973             *
19974             * @param groupId the group ID
19975             * @param userId the user ID
19976             * @param classNameId the class name ID
19977             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19978             * @return the last matching journal article
19979             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
19980             * @throws SystemException if a system exception occurred
19981             */
19982            public JournalArticle findByG_U_C_Last(long groupId, long userId,
19983                    long classNameId, OrderByComparator orderByComparator)
19984                    throws NoSuchArticleException, SystemException {
19985                    JournalArticle journalArticle = fetchByG_U_C_Last(groupId, userId,
19986                                    classNameId, orderByComparator);
19987    
19988                    if (journalArticle != null) {
19989                            return journalArticle;
19990                    }
19991    
19992                    StringBundler msg = new StringBundler(8);
19993    
19994                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
19995    
19996                    msg.append("groupId=");
19997                    msg.append(groupId);
19998    
19999                    msg.append(", userId=");
20000                    msg.append(userId);
20001    
20002                    msg.append(", classNameId=");
20003                    msg.append(classNameId);
20004    
20005                    msg.append(StringPool.CLOSE_CURLY_BRACE);
20006    
20007                    throw new NoSuchArticleException(msg.toString());
20008            }
20009    
20010            /**
20011             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
20012             *
20013             * @param groupId the group ID
20014             * @param userId the user ID
20015             * @param classNameId the class name ID
20016             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20017             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
20018             * @throws SystemException if a system exception occurred
20019             */
20020            public JournalArticle fetchByG_U_C_Last(long groupId, long userId,
20021                    long classNameId, OrderByComparator orderByComparator)
20022                    throws SystemException {
20023                    int count = countByG_U_C(groupId, userId, classNameId);
20024    
20025                    List<JournalArticle> list = findByG_U_C(groupId, userId, classNameId,
20026                                    count - 1, count, orderByComparator);
20027    
20028                    if (!list.isEmpty()) {
20029                            return list.get(0);
20030                    }
20031    
20032                    return null;
20033            }
20034    
20035            /**
20036             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
20037             *
20038             * @param id the primary key of the current journal article
20039             * @param groupId the group ID
20040             * @param userId the user ID
20041             * @param classNameId the class name ID
20042             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20043             * @return the previous, current, and next journal article
20044             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
20045             * @throws SystemException if a system exception occurred
20046             */
20047            public JournalArticle[] findByG_U_C_PrevAndNext(long id, long groupId,
20048                    long userId, long classNameId, OrderByComparator orderByComparator)
20049                    throws NoSuchArticleException, SystemException {
20050                    JournalArticle journalArticle = findByPrimaryKey(id);
20051    
20052                    Session session = null;
20053    
20054                    try {
20055                            session = openSession();
20056    
20057                            JournalArticle[] array = new JournalArticleImpl[3];
20058    
20059                            array[0] = getByG_U_C_PrevAndNext(session, journalArticle, groupId,
20060                                            userId, classNameId, orderByComparator, true);
20061    
20062                            array[1] = journalArticle;
20063    
20064                            array[2] = getByG_U_C_PrevAndNext(session, journalArticle, groupId,
20065                                            userId, classNameId, orderByComparator, false);
20066    
20067                            return array;
20068                    }
20069                    catch (Exception e) {
20070                            throw processException(e);
20071                    }
20072                    finally {
20073                            closeSession(session);
20074                    }
20075            }
20076    
20077            protected JournalArticle getByG_U_C_PrevAndNext(Session session,
20078                    JournalArticle journalArticle, long groupId, long userId,
20079                    long classNameId, OrderByComparator orderByComparator, boolean previous) {
20080                    StringBundler query = null;
20081    
20082                    if (orderByComparator != null) {
20083                            query = new StringBundler(6 +
20084                                            (orderByComparator.getOrderByFields().length * 6));
20085                    }
20086                    else {
20087                            query = new StringBundler(3);
20088                    }
20089    
20090                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
20091    
20092                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
20093    
20094                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
20095    
20096                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
20097    
20098                    if (orderByComparator != null) {
20099                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
20100    
20101                            if (orderByConditionFields.length > 0) {
20102                                    query.append(WHERE_AND);
20103                            }
20104    
20105                            for (int i = 0; i < orderByConditionFields.length; i++) {
20106                                    query.append(_ORDER_BY_ENTITY_ALIAS);
20107                                    query.append(orderByConditionFields[i]);
20108    
20109                                    if ((i + 1) < orderByConditionFields.length) {
20110                                            if (orderByComparator.isAscending() ^ previous) {
20111                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
20112                                            }
20113                                            else {
20114                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
20115                                            }
20116                                    }
20117                                    else {
20118                                            if (orderByComparator.isAscending() ^ previous) {
20119                                                    query.append(WHERE_GREATER_THAN);
20120                                            }
20121                                            else {
20122                                                    query.append(WHERE_LESSER_THAN);
20123                                            }
20124                                    }
20125                            }
20126    
20127                            query.append(ORDER_BY_CLAUSE);
20128    
20129                            String[] orderByFields = orderByComparator.getOrderByFields();
20130    
20131                            for (int i = 0; i < orderByFields.length; i++) {
20132                                    query.append(_ORDER_BY_ENTITY_ALIAS);
20133                                    query.append(orderByFields[i]);
20134    
20135                                    if ((i + 1) < orderByFields.length) {
20136                                            if (orderByComparator.isAscending() ^ previous) {
20137                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
20138                                            }
20139                                            else {
20140                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
20141                                            }
20142                                    }
20143                                    else {
20144                                            if (orderByComparator.isAscending() ^ previous) {
20145                                                    query.append(ORDER_BY_ASC);
20146                                            }
20147                                            else {
20148                                                    query.append(ORDER_BY_DESC);
20149                                            }
20150                                    }
20151                            }
20152                    }
20153                    else {
20154                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20155                    }
20156    
20157                    String sql = query.toString();
20158    
20159                    Query q = session.createQuery(sql);
20160    
20161                    q.setFirstResult(0);
20162                    q.setMaxResults(2);
20163    
20164                    QueryPos qPos = QueryPos.getInstance(q);
20165    
20166                    qPos.add(groupId);
20167    
20168                    qPos.add(userId);
20169    
20170                    qPos.add(classNameId);
20171    
20172                    if (orderByComparator != null) {
20173                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
20174    
20175                            for (Object value : values) {
20176                                    qPos.add(value);
20177                            }
20178                    }
20179    
20180                    List<JournalArticle> list = q.list();
20181    
20182                    if (list.size() == 2) {
20183                            return list.get(1);
20184                    }
20185                    else {
20186                            return null;
20187                    }
20188            }
20189    
20190            /**
20191             * Returns all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
20192             *
20193             * @param groupId the group ID
20194             * @param userId the user ID
20195             * @param classNameId the class name ID
20196             * @return the matching journal articles that the user has permission to view
20197             * @throws SystemException if a system exception occurred
20198             */
20199            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
20200                    long classNameId) throws SystemException {
20201                    return filterFindByG_U_C(groupId, userId, classNameId,
20202                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
20203            }
20204    
20205            /**
20206             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
20207             *
20208             * <p>
20209             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20210             * </p>
20211             *
20212             * @param groupId the group ID
20213             * @param userId the user ID
20214             * @param classNameId the class name ID
20215             * @param start the lower bound of the range of journal articles
20216             * @param end the upper bound of the range of journal articles (not inclusive)
20217             * @return the range of matching journal articles that the user has permission to view
20218             * @throws SystemException if a system exception occurred
20219             */
20220            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
20221                    long classNameId, int start, int end) throws SystemException {
20222                    return filterFindByG_U_C(groupId, userId, classNameId, start, end, null);
20223            }
20224    
20225            /**
20226             * 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;.
20227             *
20228             * <p>
20229             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20230             * </p>
20231             *
20232             * @param groupId the group ID
20233             * @param userId the user ID
20234             * @param classNameId the class name ID
20235             * @param start the lower bound of the range of journal articles
20236             * @param end the upper bound of the range of journal articles (not inclusive)
20237             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
20238             * @return the ordered range of matching journal articles that the user has permission to view
20239             * @throws SystemException if a system exception occurred
20240             */
20241            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
20242                    long classNameId, int start, int end,
20243                    OrderByComparator orderByComparator) throws SystemException {
20244                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20245                            return findByG_U_C(groupId, userId, classNameId, start, end,
20246                                    orderByComparator);
20247                    }
20248    
20249                    StringBundler query = null;
20250    
20251                    if (orderByComparator != null) {
20252                            query = new StringBundler(5 +
20253                                            (orderByComparator.getOrderByFields().length * 3));
20254                    }
20255                    else {
20256                            query = new StringBundler(5);
20257                    }
20258    
20259                    if (getDB().isSupportsInlineDistinct()) {
20260                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
20261                    }
20262                    else {
20263                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
20264                    }
20265    
20266                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
20267    
20268                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
20269    
20270                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
20271    
20272                    if (!getDB().isSupportsInlineDistinct()) {
20273                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
20274                    }
20275    
20276                    if (orderByComparator != null) {
20277                            if (getDB().isSupportsInlineDistinct()) {
20278                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
20279                                            orderByComparator);
20280                            }
20281                            else {
20282                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
20283                                            orderByComparator);
20284                            }
20285                    }
20286                    else {
20287                            if (getDB().isSupportsInlineDistinct()) {
20288                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20289                            }
20290                            else {
20291                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
20292                            }
20293                    }
20294    
20295                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20296                                    JournalArticle.class.getName(),
20297                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20298    
20299                    Session session = null;
20300    
20301                    try {
20302                            session = openSession();
20303    
20304                            SQLQuery q = session.createSQLQuery(sql);
20305    
20306                            if (getDB().isSupportsInlineDistinct()) {
20307                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
20308                            }
20309                            else {
20310                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
20311                            }
20312    
20313                            QueryPos qPos = QueryPos.getInstance(q);
20314    
20315                            qPos.add(groupId);
20316    
20317                            qPos.add(userId);
20318    
20319                            qPos.add(classNameId);
20320    
20321                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
20322                                    end);
20323                    }
20324                    catch (Exception e) {
20325                            throw processException(e);
20326                    }
20327                    finally {
20328                            closeSession(session);
20329                    }
20330            }
20331    
20332            /**
20333             * 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;.
20334             *
20335             * @param id the primary key of the current journal article
20336             * @param groupId the group ID
20337             * @param userId the user ID
20338             * @param classNameId the class name ID
20339             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20340             * @return the previous, current, and next journal article
20341             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
20342             * @throws SystemException if a system exception occurred
20343             */
20344            public JournalArticle[] filterFindByG_U_C_PrevAndNext(long id,
20345                    long groupId, long userId, long classNameId,
20346                    OrderByComparator orderByComparator)
20347                    throws NoSuchArticleException, SystemException {
20348                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20349                            return findByG_U_C_PrevAndNext(id, groupId, userId, classNameId,
20350                                    orderByComparator);
20351                    }
20352    
20353                    JournalArticle journalArticle = findByPrimaryKey(id);
20354    
20355                    Session session = null;
20356    
20357                    try {
20358                            session = openSession();
20359    
20360                            JournalArticle[] array = new JournalArticleImpl[3];
20361    
20362                            array[0] = filterGetByG_U_C_PrevAndNext(session, journalArticle,
20363                                            groupId, userId, classNameId, orderByComparator, true);
20364    
20365                            array[1] = journalArticle;
20366    
20367                            array[2] = filterGetByG_U_C_PrevAndNext(session, journalArticle,
20368                                            groupId, userId, classNameId, orderByComparator, false);
20369    
20370                            return array;
20371                    }
20372                    catch (Exception e) {
20373                            throw processException(e);
20374                    }
20375                    finally {
20376                            closeSession(session);
20377                    }
20378            }
20379    
20380            protected JournalArticle filterGetByG_U_C_PrevAndNext(Session session,
20381                    JournalArticle journalArticle, long groupId, long userId,
20382                    long classNameId, OrderByComparator orderByComparator, boolean previous) {
20383                    StringBundler query = null;
20384    
20385                    if (orderByComparator != null) {
20386                            query = new StringBundler(6 +
20387                                            (orderByComparator.getOrderByFields().length * 6));
20388                    }
20389                    else {
20390                            query = new StringBundler(3);
20391                    }
20392    
20393                    if (getDB().isSupportsInlineDistinct()) {
20394                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
20395                    }
20396                    else {
20397                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
20398                    }
20399    
20400                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
20401    
20402                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
20403    
20404                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
20405    
20406                    if (!getDB().isSupportsInlineDistinct()) {
20407                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
20408                    }
20409    
20410                    if (orderByComparator != null) {
20411                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
20412    
20413                            if (orderByConditionFields.length > 0) {
20414                                    query.append(WHERE_AND);
20415                            }
20416    
20417                            for (int i = 0; i < orderByConditionFields.length; i++) {
20418                                    if (getDB().isSupportsInlineDistinct()) {
20419                                            query.append(_ORDER_BY_ENTITY_ALIAS);
20420                                    }
20421                                    else {
20422                                            query.append(_ORDER_BY_ENTITY_TABLE);
20423                                    }
20424    
20425                                    query.append(orderByConditionFields[i]);
20426    
20427                                    if ((i + 1) < orderByConditionFields.length) {
20428                                            if (orderByComparator.isAscending() ^ previous) {
20429                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
20430                                            }
20431                                            else {
20432                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
20433                                            }
20434                                    }
20435                                    else {
20436                                            if (orderByComparator.isAscending() ^ previous) {
20437                                                    query.append(WHERE_GREATER_THAN);
20438                                            }
20439                                            else {
20440                                                    query.append(WHERE_LESSER_THAN);
20441                                            }
20442                                    }
20443                            }
20444    
20445                            query.append(ORDER_BY_CLAUSE);
20446    
20447                            String[] orderByFields = orderByComparator.getOrderByFields();
20448    
20449                            for (int i = 0; i < orderByFields.length; i++) {
20450                                    if (getDB().isSupportsInlineDistinct()) {
20451                                            query.append(_ORDER_BY_ENTITY_ALIAS);
20452                                    }
20453                                    else {
20454                                            query.append(_ORDER_BY_ENTITY_TABLE);
20455                                    }
20456    
20457                                    query.append(orderByFields[i]);
20458    
20459                                    if ((i + 1) < orderByFields.length) {
20460                                            if (orderByComparator.isAscending() ^ previous) {
20461                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
20462                                            }
20463                                            else {
20464                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
20465                                            }
20466                                    }
20467                                    else {
20468                                            if (orderByComparator.isAscending() ^ previous) {
20469                                                    query.append(ORDER_BY_ASC);
20470                                            }
20471                                            else {
20472                                                    query.append(ORDER_BY_DESC);
20473                                            }
20474                                    }
20475                            }
20476                    }
20477                    else {
20478                            if (getDB().isSupportsInlineDistinct()) {
20479                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20480                            }
20481                            else {
20482                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
20483                            }
20484                    }
20485    
20486                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20487                                    JournalArticle.class.getName(),
20488                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20489    
20490                    SQLQuery q = session.createSQLQuery(sql);
20491    
20492                    q.setFirstResult(0);
20493                    q.setMaxResults(2);
20494    
20495                    if (getDB().isSupportsInlineDistinct()) {
20496                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
20497                    }
20498                    else {
20499                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
20500                    }
20501    
20502                    QueryPos qPos = QueryPos.getInstance(q);
20503    
20504                    qPos.add(groupId);
20505    
20506                    qPos.add(userId);
20507    
20508                    qPos.add(classNameId);
20509    
20510                    if (orderByComparator != null) {
20511                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
20512    
20513                            for (Object value : values) {
20514                                    qPos.add(value);
20515                            }
20516                    }
20517    
20518                    List<JournalArticle> list = q.list();
20519    
20520                    if (list.size() == 2) {
20521                            return list.get(1);
20522                    }
20523                    else {
20524                            return null;
20525                    }
20526            }
20527    
20528            /**
20529             * Removes all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63; from the database.
20530             *
20531             * @param groupId the group ID
20532             * @param userId the user ID
20533             * @param classNameId the class name ID
20534             * @throws SystemException if a system exception occurred
20535             */
20536            public void removeByG_U_C(long groupId, long userId, long classNameId)
20537                    throws SystemException {
20538                    for (JournalArticle journalArticle : findByG_U_C(groupId, userId,
20539                                    classNameId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
20540                            remove(journalArticle);
20541                    }
20542            }
20543    
20544            /**
20545             * Returns the number of journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
20546             *
20547             * @param groupId the group ID
20548             * @param userId the user ID
20549             * @param classNameId the class name ID
20550             * @return the number of matching journal articles
20551             * @throws SystemException if a system exception occurred
20552             */
20553            public int countByG_U_C(long groupId, long userId, long classNameId)
20554                    throws SystemException {
20555                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_C;
20556    
20557                    Object[] finderArgs = new Object[] { groupId, userId, classNameId };
20558    
20559                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
20560                                    this);
20561    
20562                    if (count == null) {
20563                            StringBundler query = new StringBundler(4);
20564    
20565                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
20566    
20567                            query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
20568    
20569                            query.append(_FINDER_COLUMN_G_U_C_USERID_2);
20570    
20571                            query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
20572    
20573                            String sql = query.toString();
20574    
20575                            Session session = null;
20576    
20577                            try {
20578                                    session = openSession();
20579    
20580                                    Query q = session.createQuery(sql);
20581    
20582                                    QueryPos qPos = QueryPos.getInstance(q);
20583    
20584                                    qPos.add(groupId);
20585    
20586                                    qPos.add(userId);
20587    
20588                                    qPos.add(classNameId);
20589    
20590                                    count = (Long)q.uniqueResult();
20591    
20592                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
20593                            }
20594                            catch (Exception e) {
20595                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
20596    
20597                                    throw processException(e);
20598                            }
20599                            finally {
20600                                    closeSession(session);
20601                            }
20602                    }
20603    
20604                    return count.intValue();
20605            }
20606    
20607            /**
20608             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
20609             *
20610             * @param groupId the group ID
20611             * @param userId the user ID
20612             * @param classNameId the class name ID
20613             * @return the number of matching journal articles that the user has permission to view
20614             * @throws SystemException if a system exception occurred
20615             */
20616            public int filterCountByG_U_C(long groupId, long userId, long classNameId)
20617                    throws SystemException {
20618                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20619                            return countByG_U_C(groupId, userId, classNameId);
20620                    }
20621    
20622                    StringBundler query = new StringBundler(4);
20623    
20624                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
20625    
20626                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
20627    
20628                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
20629    
20630                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
20631    
20632                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20633                                    JournalArticle.class.getName(),
20634                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20635    
20636                    Session session = null;
20637    
20638                    try {
20639                            session = openSession();
20640    
20641                            SQLQuery q = session.createSQLQuery(sql);
20642    
20643                            q.addScalar(COUNT_COLUMN_NAME,
20644                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
20645    
20646                            QueryPos qPos = QueryPos.getInstance(q);
20647    
20648                            qPos.add(groupId);
20649    
20650                            qPos.add(userId);
20651    
20652                            qPos.add(classNameId);
20653    
20654                            Long count = (Long)q.uniqueResult();
20655    
20656                            return count.intValue();
20657                    }
20658                    catch (Exception e) {
20659                            throw processException(e);
20660                    }
20661                    finally {
20662                            closeSession(session);
20663                    }
20664            }
20665    
20666            private static final String _FINDER_COLUMN_G_U_C_GROUPID_2 = "journalArticle.groupId = ? AND ";
20667            private static final String _FINDER_COLUMN_G_U_C_USERID_2 = "journalArticle.userId = ? AND ";
20668            private static final String _FINDER_COLUMN_G_U_C_CLASSNAMEID_2 = "journalArticle.classNameId = ?";
20669            public static final FinderPath FINDER_PATH_FETCH_BY_G_A_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
20670                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
20671                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_A_V",
20672                            new String[] {
20673                                    Long.class.getName(), String.class.getName(),
20674                                    Double.class.getName()
20675                            },
20676                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
20677                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
20678                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
20679            public static final FinderPath FINDER_PATH_COUNT_BY_G_A_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
20680                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
20681                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A_V",
20682                            new String[] {
20683                                    Long.class.getName(), String.class.getName(),
20684                                    Double.class.getName()
20685                            });
20686    
20687            /**
20688             * 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.
20689             *
20690             * @param groupId the group ID
20691             * @param articleId the article ID
20692             * @param version the version
20693             * @return the matching journal article
20694             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
20695             * @throws SystemException if a system exception occurred
20696             */
20697            public JournalArticle findByG_A_V(long groupId, String articleId,
20698                    double version) throws NoSuchArticleException, SystemException {
20699                    JournalArticle journalArticle = fetchByG_A_V(groupId, articleId, version);
20700    
20701                    if (journalArticle == null) {
20702                            StringBundler msg = new StringBundler(8);
20703    
20704                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
20705    
20706                            msg.append("groupId=");
20707                            msg.append(groupId);
20708    
20709                            msg.append(", articleId=");
20710                            msg.append(articleId);
20711    
20712                            msg.append(", version=");
20713                            msg.append(version);
20714    
20715                            msg.append(StringPool.CLOSE_CURLY_BRACE);
20716    
20717                            if (_log.isWarnEnabled()) {
20718                                    _log.warn(msg.toString());
20719                            }
20720    
20721                            throw new NoSuchArticleException(msg.toString());
20722                    }
20723    
20724                    return journalArticle;
20725            }
20726    
20727            /**
20728             * 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.
20729             *
20730             * @param groupId the group ID
20731             * @param articleId the article ID
20732             * @param version the version
20733             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
20734             * @throws SystemException if a system exception occurred
20735             */
20736            public JournalArticle fetchByG_A_V(long groupId, String articleId,
20737                    double version) throws SystemException {
20738                    return fetchByG_A_V(groupId, articleId, version, true);
20739            }
20740    
20741            /**
20742             * 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.
20743             *
20744             * @param groupId the group ID
20745             * @param articleId the article ID
20746             * @param version the version
20747             * @param retrieveFromCache whether to use the finder cache
20748             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
20749             * @throws SystemException if a system exception occurred
20750             */
20751            public JournalArticle fetchByG_A_V(long groupId, String articleId,
20752                    double version, boolean retrieveFromCache) throws SystemException {
20753                    Object[] finderArgs = new Object[] { groupId, articleId, version };
20754    
20755                    Object result = null;
20756    
20757                    if (retrieveFromCache) {
20758                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_A_V,
20759                                            finderArgs, this);
20760                    }
20761    
20762                    if (result instanceof JournalArticle) {
20763                            JournalArticle journalArticle = (JournalArticle)result;
20764    
20765                            if ((groupId != journalArticle.getGroupId()) ||
20766                                            !Validator.equals(articleId, journalArticle.getArticleId()) ||
20767                                            (version != journalArticle.getVersion())) {
20768                                    result = null;
20769                            }
20770                    }
20771    
20772                    if (result == null) {
20773                            StringBundler query = new StringBundler(5);
20774    
20775                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
20776    
20777                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
20778    
20779                            if (articleId == null) {
20780                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
20781                            }
20782                            else {
20783                                    if (articleId.equals(StringPool.BLANK)) {
20784                                            query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
20785                                    }
20786                                    else {
20787                                            query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
20788                                    }
20789                            }
20790    
20791                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
20792    
20793                            String sql = query.toString();
20794    
20795                            Session session = null;
20796    
20797                            try {
20798                                    session = openSession();
20799    
20800                                    Query q = session.createQuery(sql);
20801    
20802                                    QueryPos qPos = QueryPos.getInstance(q);
20803    
20804                                    qPos.add(groupId);
20805    
20806                                    if (articleId != null) {
20807                                            qPos.add(articleId);
20808                                    }
20809    
20810                                    qPos.add(version);
20811    
20812                                    List<JournalArticle> list = q.list();
20813    
20814                                    if (list.isEmpty()) {
20815                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
20816                                                    finderArgs, list);
20817                                    }
20818                                    else {
20819                                            JournalArticle journalArticle = list.get(0);
20820    
20821                                            result = journalArticle;
20822    
20823                                            cacheResult(journalArticle);
20824    
20825                                            if ((journalArticle.getGroupId() != groupId) ||
20826                                                            (journalArticle.getArticleId() == null) ||
20827                                                            !journalArticle.getArticleId().equals(articleId) ||
20828                                                            (journalArticle.getVersion() != version)) {
20829                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
20830                                                            finderArgs, journalArticle);
20831                                            }
20832                                    }
20833                            }
20834                            catch (Exception e) {
20835                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V,
20836                                            finderArgs);
20837    
20838                                    throw processException(e);
20839                            }
20840                            finally {
20841                                    closeSession(session);
20842                            }
20843                    }
20844    
20845                    if (result instanceof List<?>) {
20846                            return null;
20847                    }
20848                    else {
20849                            return (JournalArticle)result;
20850                    }
20851            }
20852    
20853            /**
20854             * Removes the journal article where groupId = &#63; and articleId = &#63; and version = &#63; from the database.
20855             *
20856             * @param groupId the group ID
20857             * @param articleId the article ID
20858             * @param version the version
20859             * @return the journal article that was removed
20860             * @throws SystemException if a system exception occurred
20861             */
20862            public JournalArticle removeByG_A_V(long groupId, String articleId,
20863                    double version) throws NoSuchArticleException, SystemException {
20864                    JournalArticle journalArticle = findByG_A_V(groupId, articleId, version);
20865    
20866                    return remove(journalArticle);
20867            }
20868    
20869            /**
20870             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and version = &#63;.
20871             *
20872             * @param groupId the group ID
20873             * @param articleId the article ID
20874             * @param version the version
20875             * @return the number of matching journal articles
20876             * @throws SystemException if a system exception occurred
20877             */
20878            public int countByG_A_V(long groupId, String articleId, double version)
20879                    throws SystemException {
20880                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A_V;
20881    
20882                    Object[] finderArgs = new Object[] { groupId, articleId, version };
20883    
20884                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
20885                                    this);
20886    
20887                    if (count == null) {
20888                            StringBundler query = new StringBundler(4);
20889    
20890                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
20891    
20892                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
20893    
20894                            if (articleId == null) {
20895                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
20896                            }
20897                            else {
20898                                    if (articleId.equals(StringPool.BLANK)) {
20899                                            query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
20900                                    }
20901                                    else {
20902                                            query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
20903                                    }
20904                            }
20905    
20906                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
20907    
20908                            String sql = query.toString();
20909    
20910                            Session session = null;
20911    
20912                            try {
20913                                    session = openSession();
20914    
20915                                    Query q = session.createQuery(sql);
20916    
20917                                    QueryPos qPos = QueryPos.getInstance(q);
20918    
20919                                    qPos.add(groupId);
20920    
20921                                    if (articleId != null) {
20922                                            qPos.add(articleId);
20923                                    }
20924    
20925                                    qPos.add(version);
20926    
20927                                    count = (Long)q.uniqueResult();
20928    
20929                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
20930                            }
20931                            catch (Exception e) {
20932                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
20933    
20934                                    throw processException(e);
20935                            }
20936                            finally {
20937                                    closeSession(session);
20938                            }
20939                    }
20940    
20941                    return count.intValue();
20942            }
20943    
20944            private static final String _FINDER_COLUMN_G_A_V_GROUPID_2 = "journalArticle.groupId = ? AND ";
20945            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
20946            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
20947            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = ?) AND ";
20948            private static final String _FINDER_COLUMN_G_A_V_VERSION_2 = "journalArticle.version = ?";
20949            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
20950                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
20951                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
20952                            "findByG_A_ST",
20953                            new String[] {
20954                                    Long.class.getName(), String.class.getName(),
20955                                    Integer.class.getName(),
20956                                    
20957                            Integer.class.getName(), Integer.class.getName(),
20958                                    OrderByComparator.class.getName()
20959                            });
20960            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST =
20961                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
20962                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
20963                            JournalArticleImpl.class,
20964                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A_ST",
20965                            new String[] {
20966                                    Long.class.getName(), String.class.getName(),
20967                                    Integer.class.getName()
20968                            },
20969                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
20970                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
20971                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
20972                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
20973            public static final FinderPath FINDER_PATH_COUNT_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
20974                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
20975                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A_ST",
20976                            new String[] {
20977                                    Long.class.getName(), String.class.getName(),
20978                                    Integer.class.getName()
20979                            });
20980            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
20981                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
20982                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_A_ST",
20983                            new String[] {
20984                                    Long.class.getName(), String.class.getName(),
20985                                    Integer.class.getName()
20986                            });
20987    
20988            /**
20989             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
20990             *
20991             * @param groupId the group ID
20992             * @param articleId the article ID
20993             * @param status the status
20994             * @return the matching journal articles
20995             * @throws SystemException if a system exception occurred
20996             */
20997            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
20998                    int status) throws SystemException {
20999                    return findByG_A_ST(groupId, articleId, status, QueryUtil.ALL_POS,
21000                            QueryUtil.ALL_POS, null);
21001            }
21002    
21003            /**
21004             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
21005             *
21006             * <p>
21007             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
21008             * </p>
21009             *
21010             * @param groupId the group ID
21011             * @param articleId the article ID
21012             * @param status the status
21013             * @param start the lower bound of the range of journal articles
21014             * @param end the upper bound of the range of journal articles (not inclusive)
21015             * @return the range of matching journal articles
21016             * @throws SystemException if a system exception occurred
21017             */
21018            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
21019                    int status, int start, int end) throws SystemException {
21020                    return findByG_A_ST(groupId, articleId, status, start, end, null);
21021            }
21022    
21023            /**
21024             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
21025             *
21026             * <p>
21027             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
21028             * </p>
21029             *
21030             * @param groupId the group ID
21031             * @param articleId the article ID
21032             * @param status the status
21033             * @param start the lower bound of the range of journal articles
21034             * @param end the upper bound of the range of journal articles (not inclusive)
21035             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
21036             * @return the ordered range of matching journal articles
21037             * @throws SystemException if a system exception occurred
21038             */
21039            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
21040                    int status, int start, int end, OrderByComparator orderByComparator)
21041                    throws SystemException {
21042                    boolean pagination = true;
21043                    FinderPath finderPath = null;
21044                    Object[] finderArgs = null;
21045    
21046                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
21047                                    (orderByComparator == null)) {
21048                            pagination = false;
21049                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST;
21050                            finderArgs = new Object[] { groupId, articleId, status };
21051                    }
21052                    else {
21053                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST;
21054                            finderArgs = new Object[] {
21055                                            groupId, articleId, status,
21056                                            
21057                                            start, end, orderByComparator
21058                                    };
21059                    }
21060    
21061                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
21062                                    finderArgs, this);
21063    
21064                    if ((list != null) && !list.isEmpty()) {
21065                            for (JournalArticle journalArticle : list) {
21066                                    if ((groupId != journalArticle.getGroupId()) ||
21067                                                    !Validator.equals(articleId,
21068                                                            journalArticle.getArticleId()) ||
21069                                                    (status != journalArticle.getStatus())) {
21070                                            list = null;
21071    
21072                                            break;
21073                                    }
21074                            }
21075                    }
21076    
21077                    if (list == null) {
21078                            StringBundler query = null;
21079    
21080                            if (orderByComparator != null) {
21081                                    query = new StringBundler(5 +
21082                                                    (orderByComparator.getOrderByFields().length * 3));
21083                            }
21084                            else {
21085                                    query = new StringBundler(5);
21086                            }
21087    
21088                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
21089    
21090                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
21091    
21092                            if (articleId == null) {
21093                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
21094                            }
21095                            else {
21096                                    if (articleId.equals(StringPool.BLANK)) {
21097                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
21098                                    }
21099                                    else {
21100                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
21101                                    }
21102                            }
21103    
21104                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
21105    
21106                            if (orderByComparator != null) {
21107                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
21108                                            orderByComparator);
21109                            }
21110                            else
21111                             if (pagination) {
21112                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21113                            }
21114    
21115                            String sql = query.toString();
21116    
21117                            Session session = null;
21118    
21119                            try {
21120                                    session = openSession();
21121    
21122                                    Query q = session.createQuery(sql);
21123    
21124                                    QueryPos qPos = QueryPos.getInstance(q);
21125    
21126                                    qPos.add(groupId);
21127    
21128                                    if (articleId != null) {
21129                                            qPos.add(articleId);
21130                                    }
21131    
21132                                    qPos.add(status);
21133    
21134                                    if (!pagination) {
21135                                            list = (List<JournalArticle>)QueryUtil.list(q,
21136                                                            getDialect(), start, end, false);
21137    
21138                                            Collections.sort(list);
21139    
21140                                            list = new UnmodifiableList<JournalArticle>(list);
21141                                    }
21142                                    else {
21143                                            list = (List<JournalArticle>)QueryUtil.list(q,
21144                                                            getDialect(), start, end);
21145                                    }
21146    
21147                                    cacheResult(list);
21148    
21149                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
21150                            }
21151                            catch (Exception e) {
21152                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
21153    
21154                                    throw processException(e);
21155                            }
21156                            finally {
21157                                    closeSession(session);
21158                            }
21159                    }
21160    
21161                    return list;
21162            }
21163    
21164            /**
21165             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
21166             *
21167             * @param groupId the group ID
21168             * @param articleId the article ID
21169             * @param status the status
21170             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21171             * @return the first matching journal article
21172             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
21173             * @throws SystemException if a system exception occurred
21174             */
21175            public JournalArticle findByG_A_ST_First(long groupId, String articleId,
21176                    int status, OrderByComparator orderByComparator)
21177                    throws NoSuchArticleException, SystemException {
21178                    JournalArticle journalArticle = fetchByG_A_ST_First(groupId, articleId,
21179                                    status, orderByComparator);
21180    
21181                    if (journalArticle != null) {
21182                            return journalArticle;
21183                    }
21184    
21185                    StringBundler msg = new StringBundler(8);
21186    
21187                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
21188    
21189                    msg.append("groupId=");
21190                    msg.append(groupId);
21191    
21192                    msg.append(", articleId=");
21193                    msg.append(articleId);
21194    
21195                    msg.append(", status=");
21196                    msg.append(status);
21197    
21198                    msg.append(StringPool.CLOSE_CURLY_BRACE);
21199    
21200                    throw new NoSuchArticleException(msg.toString());
21201            }
21202    
21203            /**
21204             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
21205             *
21206             * @param groupId the group ID
21207             * @param articleId the article ID
21208             * @param status the status
21209             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21210             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
21211             * @throws SystemException if a system exception occurred
21212             */
21213            public JournalArticle fetchByG_A_ST_First(long groupId, String articleId,
21214                    int status, OrderByComparator orderByComparator)
21215                    throws SystemException {
21216                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status, 0,
21217                                    1, orderByComparator);
21218    
21219                    if (!list.isEmpty()) {
21220                            return list.get(0);
21221                    }
21222    
21223                    return null;
21224            }
21225    
21226            /**
21227             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
21228             *
21229             * @param groupId the group ID
21230             * @param articleId the article ID
21231             * @param status the status
21232             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21233             * @return the last matching journal article
21234             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
21235             * @throws SystemException if a system exception occurred
21236             */
21237            public JournalArticle findByG_A_ST_Last(long groupId, String articleId,
21238                    int status, OrderByComparator orderByComparator)
21239                    throws NoSuchArticleException, SystemException {
21240                    JournalArticle journalArticle = fetchByG_A_ST_Last(groupId, articleId,
21241                                    status, orderByComparator);
21242    
21243                    if (journalArticle != null) {
21244                            return journalArticle;
21245                    }
21246    
21247                    StringBundler msg = new StringBundler(8);
21248    
21249                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
21250    
21251                    msg.append("groupId=");
21252                    msg.append(groupId);
21253    
21254                    msg.append(", articleId=");
21255                    msg.append(articleId);
21256    
21257                    msg.append(", status=");
21258                    msg.append(status);
21259    
21260                    msg.append(StringPool.CLOSE_CURLY_BRACE);
21261    
21262                    throw new NoSuchArticleException(msg.toString());
21263            }
21264    
21265            /**
21266             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
21267             *
21268             * @param groupId the group ID
21269             * @param articleId the article ID
21270             * @param status the status
21271             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21272             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
21273             * @throws SystemException if a system exception occurred
21274             */
21275            public JournalArticle fetchByG_A_ST_Last(long groupId, String articleId,
21276                    int status, OrderByComparator orderByComparator)
21277                    throws SystemException {
21278                    int count = countByG_A_ST(groupId, articleId, status);
21279    
21280                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status,
21281                                    count - 1, count, orderByComparator);
21282    
21283                    if (!list.isEmpty()) {
21284                            return list.get(0);
21285                    }
21286    
21287                    return null;
21288            }
21289    
21290            /**
21291             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
21292             *
21293             * @param id the primary key of the current journal article
21294             * @param groupId the group ID
21295             * @param articleId the article ID
21296             * @param status the status
21297             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21298             * @return the previous, current, and next journal article
21299             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
21300             * @throws SystemException if a system exception occurred
21301             */
21302            public JournalArticle[] findByG_A_ST_PrevAndNext(long id, long groupId,
21303                    String articleId, int status, OrderByComparator orderByComparator)
21304                    throws NoSuchArticleException, SystemException {
21305                    JournalArticle journalArticle = findByPrimaryKey(id);
21306    
21307                    Session session = null;
21308    
21309                    try {
21310                            session = openSession();
21311    
21312                            JournalArticle[] array = new JournalArticleImpl[3];
21313    
21314                            array[0] = getByG_A_ST_PrevAndNext(session, journalArticle,
21315                                            groupId, articleId, status, orderByComparator, true);
21316    
21317                            array[1] = journalArticle;
21318    
21319                            array[2] = getByG_A_ST_PrevAndNext(session, journalArticle,
21320                                            groupId, articleId, status, orderByComparator, false);
21321    
21322                            return array;
21323                    }
21324                    catch (Exception e) {
21325                            throw processException(e);
21326                    }
21327                    finally {
21328                            closeSession(session);
21329                    }
21330            }
21331    
21332            protected JournalArticle getByG_A_ST_PrevAndNext(Session session,
21333                    JournalArticle journalArticle, long groupId, String articleId,
21334                    int status, OrderByComparator orderByComparator, boolean previous) {
21335                    StringBundler query = null;
21336    
21337                    if (orderByComparator != null) {
21338                            query = new StringBundler(6 +
21339                                            (orderByComparator.getOrderByFields().length * 6));
21340                    }
21341                    else {
21342                            query = new StringBundler(3);
21343                    }
21344    
21345                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
21346    
21347                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
21348    
21349                    if (articleId == null) {
21350                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
21351                    }
21352                    else {
21353                            if (articleId.equals(StringPool.BLANK)) {
21354                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
21355                            }
21356                            else {
21357                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
21358                            }
21359                    }
21360    
21361                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
21362    
21363                    if (orderByComparator != null) {
21364                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
21365    
21366                            if (orderByConditionFields.length > 0) {
21367                                    query.append(WHERE_AND);
21368                            }
21369    
21370                            for (int i = 0; i < orderByConditionFields.length; i++) {
21371                                    query.append(_ORDER_BY_ENTITY_ALIAS);
21372                                    query.append(orderByConditionFields[i]);
21373    
21374                                    if ((i + 1) < orderByConditionFields.length) {
21375                                            if (orderByComparator.isAscending() ^ previous) {
21376                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
21377                                            }
21378                                            else {
21379                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
21380                                            }
21381                                    }
21382                                    else {
21383                                            if (orderByComparator.isAscending() ^ previous) {
21384                                                    query.append(WHERE_GREATER_THAN);
21385                                            }
21386                                            else {
21387                                                    query.append(WHERE_LESSER_THAN);
21388                                            }
21389                                    }
21390                            }
21391    
21392                            query.append(ORDER_BY_CLAUSE);
21393    
21394                            String[] orderByFields = orderByComparator.getOrderByFields();
21395    
21396                            for (int i = 0; i < orderByFields.length; i++) {
21397                                    query.append(_ORDER_BY_ENTITY_ALIAS);
21398                                    query.append(orderByFields[i]);
21399    
21400                                    if ((i + 1) < orderByFields.length) {
21401                                            if (orderByComparator.isAscending() ^ previous) {
21402                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
21403                                            }
21404                                            else {
21405                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
21406                                            }
21407                                    }
21408                                    else {
21409                                            if (orderByComparator.isAscending() ^ previous) {
21410                                                    query.append(ORDER_BY_ASC);
21411                                            }
21412                                            else {
21413                                                    query.append(ORDER_BY_DESC);
21414                                            }
21415                                    }
21416                            }
21417                    }
21418                    else {
21419                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21420                    }
21421    
21422                    String sql = query.toString();
21423    
21424                    Query q = session.createQuery(sql);
21425    
21426                    q.setFirstResult(0);
21427                    q.setMaxResults(2);
21428    
21429                    QueryPos qPos = QueryPos.getInstance(q);
21430    
21431                    qPos.add(groupId);
21432    
21433                    if (articleId != null) {
21434                            qPos.add(articleId);
21435                    }
21436    
21437                    qPos.add(status);
21438    
21439                    if (orderByComparator != null) {
21440                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
21441    
21442                            for (Object value : values) {
21443                                    qPos.add(value);
21444                            }
21445                    }
21446    
21447                    List<JournalArticle> list = q.list();
21448    
21449                    if (list.size() == 2) {
21450                            return list.get(1);
21451                    }
21452                    else {
21453                            return null;
21454                    }
21455            }
21456    
21457            /**
21458             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
21459             *
21460             * @param groupId the group ID
21461             * @param articleId the article ID
21462             * @param status the status
21463             * @return the matching journal articles that the user has permission to view
21464             * @throws SystemException if a system exception occurred
21465             */
21466            public List<JournalArticle> filterFindByG_A_ST(long groupId,
21467                    String articleId, int status) throws SystemException {
21468                    return filterFindByG_A_ST(groupId, articleId, status,
21469                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
21470            }
21471    
21472            /**
21473             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
21474             *
21475             * <p>
21476             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
21477             * </p>
21478             *
21479             * @param groupId the group ID
21480             * @param articleId the article ID
21481             * @param status the status
21482             * @param start the lower bound of the range of journal articles
21483             * @param end the upper bound of the range of journal articles (not inclusive)
21484             * @return the range of matching journal articles that the user has permission to view
21485             * @throws SystemException if a system exception occurred
21486             */
21487            public List<JournalArticle> filterFindByG_A_ST(long groupId,
21488                    String articleId, int status, int start, int end)
21489                    throws SystemException {
21490                    return filterFindByG_A_ST(groupId, articleId, status, start, end, null);
21491            }
21492    
21493            /**
21494             * 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;.
21495             *
21496             * <p>
21497             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
21498             * </p>
21499             *
21500             * @param groupId the group ID
21501             * @param articleId the article ID
21502             * @param status the status
21503             * @param start the lower bound of the range of journal articles
21504             * @param end the upper bound of the range of journal articles (not inclusive)
21505             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
21506             * @return the ordered range of matching journal articles that the user has permission to view
21507             * @throws SystemException if a system exception occurred
21508             */
21509            public List<JournalArticle> filterFindByG_A_ST(long groupId,
21510                    String articleId, int status, int start, int end,
21511                    OrderByComparator orderByComparator) throws SystemException {
21512                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21513                            return findByG_A_ST(groupId, articleId, status, start, end,
21514                                    orderByComparator);
21515                    }
21516    
21517                    StringBundler query = null;
21518    
21519                    if (orderByComparator != null) {
21520                            query = new StringBundler(5 +
21521                                            (orderByComparator.getOrderByFields().length * 3));
21522                    }
21523                    else {
21524                            query = new StringBundler(5);
21525                    }
21526    
21527                    if (getDB().isSupportsInlineDistinct()) {
21528                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
21529                    }
21530                    else {
21531                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
21532                    }
21533    
21534                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
21535    
21536                    if (articleId == null) {
21537                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
21538                    }
21539                    else {
21540                            if (articleId.equals(StringPool.BLANK)) {
21541                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
21542                            }
21543                            else {
21544                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
21545                            }
21546                    }
21547    
21548                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
21549    
21550                    if (!getDB().isSupportsInlineDistinct()) {
21551                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
21552                    }
21553    
21554                    if (orderByComparator != null) {
21555                            if (getDB().isSupportsInlineDistinct()) {
21556                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
21557                                            orderByComparator);
21558                            }
21559                            else {
21560                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
21561                                            orderByComparator);
21562                            }
21563                    }
21564                    else {
21565                            if (getDB().isSupportsInlineDistinct()) {
21566                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21567                            }
21568                            else {
21569                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
21570                            }
21571                    }
21572    
21573                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21574                                    JournalArticle.class.getName(),
21575                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21576    
21577                    Session session = null;
21578    
21579                    try {
21580                            session = openSession();
21581    
21582                            SQLQuery q = session.createSQLQuery(sql);
21583    
21584                            if (getDB().isSupportsInlineDistinct()) {
21585                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
21586                            }
21587                            else {
21588                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
21589                            }
21590    
21591                            QueryPos qPos = QueryPos.getInstance(q);
21592    
21593                            qPos.add(groupId);
21594    
21595                            if (articleId != null) {
21596                                    qPos.add(articleId);
21597                            }
21598    
21599                            qPos.add(status);
21600    
21601                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
21602                                    end);
21603                    }
21604                    catch (Exception e) {
21605                            throw processException(e);
21606                    }
21607                    finally {
21608                            closeSession(session);
21609                    }
21610            }
21611    
21612            /**
21613             * 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;.
21614             *
21615             * @param id the primary key of the current journal article
21616             * @param groupId the group ID
21617             * @param articleId the article ID
21618             * @param status the status
21619             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21620             * @return the previous, current, and next journal article
21621             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
21622             * @throws SystemException if a system exception occurred
21623             */
21624            public JournalArticle[] filterFindByG_A_ST_PrevAndNext(long id,
21625                    long groupId, String articleId, int status,
21626                    OrderByComparator orderByComparator)
21627                    throws NoSuchArticleException, SystemException {
21628                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21629                            return findByG_A_ST_PrevAndNext(id, groupId, articleId, status,
21630                                    orderByComparator);
21631                    }
21632    
21633                    JournalArticle journalArticle = findByPrimaryKey(id);
21634    
21635                    Session session = null;
21636    
21637                    try {
21638                            session = openSession();
21639    
21640                            JournalArticle[] array = new JournalArticleImpl[3];
21641    
21642                            array[0] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
21643                                            groupId, articleId, status, orderByComparator, true);
21644    
21645                            array[1] = journalArticle;
21646    
21647                            array[2] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
21648                                            groupId, articleId, status, orderByComparator, false);
21649    
21650                            return array;
21651                    }
21652                    catch (Exception e) {
21653                            throw processException(e);
21654                    }
21655                    finally {
21656                            closeSession(session);
21657                    }
21658            }
21659    
21660            protected JournalArticle filterGetByG_A_ST_PrevAndNext(Session session,
21661                    JournalArticle journalArticle, long groupId, String articleId,
21662                    int status, OrderByComparator orderByComparator, boolean previous) {
21663                    StringBundler query = null;
21664    
21665                    if (orderByComparator != null) {
21666                            query = new StringBundler(6 +
21667                                            (orderByComparator.getOrderByFields().length * 6));
21668                    }
21669                    else {
21670                            query = new StringBundler(3);
21671                    }
21672    
21673                    if (getDB().isSupportsInlineDistinct()) {
21674                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
21675                    }
21676                    else {
21677                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
21678                    }
21679    
21680                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
21681    
21682                    if (articleId == null) {
21683                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
21684                    }
21685                    else {
21686                            if (articleId.equals(StringPool.BLANK)) {
21687                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
21688                            }
21689                            else {
21690                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
21691                            }
21692                    }
21693    
21694                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
21695    
21696                    if (!getDB().isSupportsInlineDistinct()) {
21697                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
21698                    }
21699    
21700                    if (orderByComparator != null) {
21701                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
21702    
21703                            if (orderByConditionFields.length > 0) {
21704                                    query.append(WHERE_AND);
21705                            }
21706    
21707                            for (int i = 0; i < orderByConditionFields.length; i++) {
21708                                    if (getDB().isSupportsInlineDistinct()) {
21709                                            query.append(_ORDER_BY_ENTITY_ALIAS);
21710                                    }
21711                                    else {
21712                                            query.append(_ORDER_BY_ENTITY_TABLE);
21713                                    }
21714    
21715                                    query.append(orderByConditionFields[i]);
21716    
21717                                    if ((i + 1) < orderByConditionFields.length) {
21718                                            if (orderByComparator.isAscending() ^ previous) {
21719                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
21720                                            }
21721                                            else {
21722                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
21723                                            }
21724                                    }
21725                                    else {
21726                                            if (orderByComparator.isAscending() ^ previous) {
21727                                                    query.append(WHERE_GREATER_THAN);
21728                                            }
21729                                            else {
21730                                                    query.append(WHERE_LESSER_THAN);
21731                                            }
21732                                    }
21733                            }
21734    
21735                            query.append(ORDER_BY_CLAUSE);
21736    
21737                            String[] orderByFields = orderByComparator.getOrderByFields();
21738    
21739                            for (int i = 0; i < orderByFields.length; i++) {
21740                                    if (getDB().isSupportsInlineDistinct()) {
21741                                            query.append(_ORDER_BY_ENTITY_ALIAS);
21742                                    }
21743                                    else {
21744                                            query.append(_ORDER_BY_ENTITY_TABLE);
21745                                    }
21746    
21747                                    query.append(orderByFields[i]);
21748    
21749                                    if ((i + 1) < orderByFields.length) {
21750                                            if (orderByComparator.isAscending() ^ previous) {
21751                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
21752                                            }
21753                                            else {
21754                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
21755                                            }
21756                                    }
21757                                    else {
21758                                            if (orderByComparator.isAscending() ^ previous) {
21759                                                    query.append(ORDER_BY_ASC);
21760                                            }
21761                                            else {
21762                                                    query.append(ORDER_BY_DESC);
21763                                            }
21764                                    }
21765                            }
21766                    }
21767                    else {
21768                            if (getDB().isSupportsInlineDistinct()) {
21769                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21770                            }
21771                            else {
21772                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
21773                            }
21774                    }
21775    
21776                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21777                                    JournalArticle.class.getName(),
21778                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21779    
21780                    SQLQuery q = session.createSQLQuery(sql);
21781    
21782                    q.setFirstResult(0);
21783                    q.setMaxResults(2);
21784    
21785                    if (getDB().isSupportsInlineDistinct()) {
21786                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
21787                    }
21788                    else {
21789                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
21790                    }
21791    
21792                    QueryPos qPos = QueryPos.getInstance(q);
21793    
21794                    qPos.add(groupId);
21795    
21796                    if (articleId != null) {
21797                            qPos.add(articleId);
21798                    }
21799    
21800                    qPos.add(status);
21801    
21802                    if (orderByComparator != null) {
21803                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
21804    
21805                            for (Object value : values) {
21806                                    qPos.add(value);
21807                            }
21808                    }
21809    
21810                    List<JournalArticle> list = q.list();
21811    
21812                    if (list.size() == 2) {
21813                            return list.get(1);
21814                    }
21815                    else {
21816                            return null;
21817                    }
21818            }
21819    
21820            /**
21821             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
21822             *
21823             * @param groupId the group ID
21824             * @param articleId the article ID
21825             * @param statuses the statuses
21826             * @return the matching journal articles that the user has permission to view
21827             * @throws SystemException if a system exception occurred
21828             */
21829            public List<JournalArticle> filterFindByG_A_ST(long groupId,
21830                    String articleId, int[] statuses) throws SystemException {
21831                    return filterFindByG_A_ST(groupId, articleId, statuses,
21832                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
21833            }
21834    
21835            /**
21836             * 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;.
21837             *
21838             * <p>
21839             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
21840             * </p>
21841             *
21842             * @param groupId the group ID
21843             * @param articleId the article ID
21844             * @param statuses the statuses
21845             * @param start the lower bound of the range of journal articles
21846             * @param end the upper bound of the range of journal articles (not inclusive)
21847             * @return the range of matching journal articles that the user has permission to view
21848             * @throws SystemException if a system exception occurred
21849             */
21850            public List<JournalArticle> filterFindByG_A_ST(long groupId,
21851                    String articleId, int[] statuses, int start, int end)
21852                    throws SystemException {
21853                    return filterFindByG_A_ST(groupId, articleId, statuses, start, end, null);
21854            }
21855    
21856            /**
21857             * 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;.
21858             *
21859             * <p>
21860             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
21861             * </p>
21862             *
21863             * @param groupId the group ID
21864             * @param articleId the article ID
21865             * @param statuses the statuses
21866             * @param start the lower bound of the range of journal articles
21867             * @param end the upper bound of the range of journal articles (not inclusive)
21868             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
21869             * @return the ordered range of matching journal articles that the user has permission to view
21870             * @throws SystemException if a system exception occurred
21871             */
21872            public List<JournalArticle> filterFindByG_A_ST(long groupId,
21873                    String articleId, int[] statuses, int start, int end,
21874                    OrderByComparator orderByComparator) throws SystemException {
21875                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21876                            return findByG_A_ST(groupId, articleId, statuses, start, end,
21877                                    orderByComparator);
21878                    }
21879    
21880                    StringBundler query = new StringBundler();
21881    
21882                    if (getDB().isSupportsInlineDistinct()) {
21883                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
21884                    }
21885                    else {
21886                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
21887                    }
21888    
21889                    boolean conjunctionable = false;
21890    
21891                    if (conjunctionable) {
21892                            query.append(WHERE_AND);
21893                    }
21894    
21895                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
21896    
21897                    conjunctionable = true;
21898    
21899                    if (conjunctionable) {
21900                            query.append(WHERE_AND);
21901                    }
21902    
21903                    if (articleId == null) {
21904                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
21905                    }
21906                    else {
21907                            if (articleId.equals(StringPool.BLANK)) {
21908                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
21909                            }
21910                            else {
21911                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
21912                            }
21913                    }
21914    
21915                    conjunctionable = true;
21916    
21917                    if ((statuses == null) || (statuses.length > 0)) {
21918                            if (conjunctionable) {
21919                                    query.append(WHERE_AND);
21920                            }
21921    
21922                            query.append(StringPool.OPEN_PARENTHESIS);
21923    
21924                            for (int i = 0; i < statuses.length; i++) {
21925                                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
21926    
21927                                    if ((i + 1) < statuses.length) {
21928                                            query.append(WHERE_OR);
21929                                    }
21930                            }
21931    
21932                            query.append(StringPool.CLOSE_PARENTHESIS);
21933    
21934                            conjunctionable = true;
21935                    }
21936    
21937                    if (!getDB().isSupportsInlineDistinct()) {
21938                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
21939                    }
21940    
21941                    if (orderByComparator != null) {
21942                            if (getDB().isSupportsInlineDistinct()) {
21943                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
21944                                            orderByComparator);
21945                            }
21946                            else {
21947                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
21948                                            orderByComparator);
21949                            }
21950                    }
21951                    else {
21952                            if (getDB().isSupportsInlineDistinct()) {
21953                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21954                            }
21955                            else {
21956                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
21957                            }
21958                    }
21959    
21960                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21961                                    JournalArticle.class.getName(),
21962                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21963    
21964                    Session session = null;
21965    
21966                    try {
21967                            session = openSession();
21968    
21969                            SQLQuery q = session.createSQLQuery(sql);
21970    
21971                            if (getDB().isSupportsInlineDistinct()) {
21972                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
21973                            }
21974                            else {
21975                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
21976                            }
21977    
21978                            QueryPos qPos = QueryPos.getInstance(q);
21979    
21980                            qPos.add(groupId);
21981    
21982                            if (articleId != null) {
21983                                    qPos.add(articleId);
21984                            }
21985    
21986                            if (statuses != null) {
21987                                    qPos.add(statuses);
21988                            }
21989    
21990                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
21991                                    end);
21992                    }
21993                    catch (Exception e) {
21994                            throw processException(e);
21995                    }
21996                    finally {
21997                            closeSession(session);
21998                    }
21999            }
22000    
22001            /**
22002             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
22003             *
22004             * <p>
22005             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22006             * </p>
22007             *
22008             * @param groupId the group ID
22009             * @param articleId the article ID
22010             * @param statuses the statuses
22011             * @return the matching journal articles
22012             * @throws SystemException if a system exception occurred
22013             */
22014            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
22015                    int[] statuses) throws SystemException {
22016                    return findByG_A_ST(groupId, articleId, statuses, QueryUtil.ALL_POS,
22017                            QueryUtil.ALL_POS, null);
22018            }
22019    
22020            /**
22021             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
22022             *
22023             * <p>
22024             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22025             * </p>
22026             *
22027             * @param groupId the group ID
22028             * @param articleId the article ID
22029             * @param statuses the statuses
22030             * @param start the lower bound of the range of journal articles
22031             * @param end the upper bound of the range of journal articles (not inclusive)
22032             * @return the range of matching journal articles
22033             * @throws SystemException if a system exception occurred
22034             */
22035            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
22036                    int[] statuses, int start, int end) throws SystemException {
22037                    return findByG_A_ST(groupId, articleId, statuses, start, end, null);
22038            }
22039    
22040            /**
22041             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
22042             *
22043             * <p>
22044             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22045             * </p>
22046             *
22047             * @param groupId the group ID
22048             * @param articleId the article ID
22049             * @param statuses the statuses
22050             * @param start the lower bound of the range of journal articles
22051             * @param end the upper bound of the range of journal articles (not inclusive)
22052             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
22053             * @return the ordered range of matching journal articles
22054             * @throws SystemException if a system exception occurred
22055             */
22056            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
22057                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
22058                    throws SystemException {
22059                    if ((statuses != null) && (statuses.length == 1)) {
22060                            return findByG_A_ST(groupId, articleId, statuses[0], start, end,
22061                                    orderByComparator);
22062                    }
22063    
22064                    boolean pagination = true;
22065                    Object[] finderArgs = null;
22066    
22067                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
22068                                    (orderByComparator == null)) {
22069                            pagination = false;
22070                            finderArgs = new Object[] {
22071                                            groupId, articleId, StringUtil.merge(statuses)
22072                                    };
22073                    }
22074                    else {
22075                            finderArgs = new Object[] {
22076                                            groupId, articleId, StringUtil.merge(statuses),
22077                                            
22078                                            start, end, orderByComparator
22079                                    };
22080                    }
22081    
22082                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
22083                                    finderArgs, this);
22084    
22085                    if ((list != null) && !list.isEmpty()) {
22086                            for (JournalArticle journalArticle : list) {
22087                                    if ((groupId != journalArticle.getGroupId()) ||
22088                                                    !Validator.equals(articleId,
22089                                                            journalArticle.getArticleId()) ||
22090                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
22091                                            list = null;
22092    
22093                                            break;
22094                                    }
22095                            }
22096                    }
22097    
22098                    if (list == null) {
22099                            StringBundler query = new StringBundler();
22100    
22101                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
22102    
22103                            boolean conjunctionable = false;
22104    
22105                            if (conjunctionable) {
22106                                    query.append(WHERE_AND);
22107                            }
22108    
22109                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
22110    
22111                            conjunctionable = true;
22112    
22113                            if (conjunctionable) {
22114                                    query.append(WHERE_AND);
22115                            }
22116    
22117                            if (articleId == null) {
22118                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
22119                            }
22120                            else {
22121                                    if (articleId.equals(StringPool.BLANK)) {
22122                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
22123                                    }
22124                                    else {
22125                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
22126                                    }
22127                            }
22128    
22129                            conjunctionable = true;
22130    
22131                            if ((statuses == null) || (statuses.length > 0)) {
22132                                    if (conjunctionable) {
22133                                            query.append(WHERE_AND);
22134                                    }
22135    
22136                                    query.append(StringPool.OPEN_PARENTHESIS);
22137    
22138                                    for (int i = 0; i < statuses.length; i++) {
22139                                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
22140    
22141                                            if ((i + 1) < statuses.length) {
22142                                                    query.append(WHERE_OR);
22143                                            }
22144                                    }
22145    
22146                                    query.append(StringPool.CLOSE_PARENTHESIS);
22147    
22148                                    conjunctionable = true;
22149                            }
22150    
22151                            if (orderByComparator != null) {
22152                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
22153                                            orderByComparator);
22154                            }
22155                            else
22156                             if (pagination) {
22157                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22158                            }
22159    
22160                            String sql = query.toString();
22161    
22162                            Session session = null;
22163    
22164                            try {
22165                                    session = openSession();
22166    
22167                                    Query q = session.createQuery(sql);
22168    
22169                                    QueryPos qPos = QueryPos.getInstance(q);
22170    
22171                                    qPos.add(groupId);
22172    
22173                                    if (articleId != null) {
22174                                            qPos.add(articleId);
22175                                    }
22176    
22177                                    if (statuses != null) {
22178                                            qPos.add(statuses);
22179                                    }
22180    
22181                                    if (!pagination) {
22182                                            list = (List<JournalArticle>)QueryUtil.list(q,
22183                                                            getDialect(), start, end, false);
22184    
22185                                            Collections.sort(list);
22186    
22187                                            list = new UnmodifiableList<JournalArticle>(list);
22188                                    }
22189                                    else {
22190                                            list = (List<JournalArticle>)QueryUtil.list(q,
22191                                                            getDialect(), start, end);
22192                                    }
22193    
22194                                    cacheResult(list);
22195    
22196                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
22197                                            finderArgs, list);
22198                            }
22199                            catch (Exception e) {
22200                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
22201                                            finderArgs);
22202    
22203                                    throw processException(e);
22204                            }
22205                            finally {
22206                                    closeSession(session);
22207                            }
22208                    }
22209    
22210                    return list;
22211            }
22212    
22213            /**
22214             * Removes all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63; from the database.
22215             *
22216             * @param groupId the group ID
22217             * @param articleId the article ID
22218             * @param status the status
22219             * @throws SystemException if a system exception occurred
22220             */
22221            public void removeByG_A_ST(long groupId, String articleId, int status)
22222                    throws SystemException {
22223                    for (JournalArticle journalArticle : findByG_A_ST(groupId, articleId,
22224                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
22225                            remove(journalArticle);
22226                    }
22227            }
22228    
22229            /**
22230             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
22231             *
22232             * @param groupId the group ID
22233             * @param articleId the article ID
22234             * @param status the status
22235             * @return the number of matching journal articles
22236             * @throws SystemException if a system exception occurred
22237             */
22238            public int countByG_A_ST(long groupId, String articleId, int status)
22239                    throws SystemException {
22240                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A_ST;
22241    
22242                    Object[] finderArgs = new Object[] { groupId, articleId, status };
22243    
22244                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
22245                                    this);
22246    
22247                    if (count == null) {
22248                            StringBundler query = new StringBundler(4);
22249    
22250                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
22251    
22252                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
22253    
22254                            if (articleId == null) {
22255                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
22256                            }
22257                            else {
22258                                    if (articleId.equals(StringPool.BLANK)) {
22259                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
22260                                    }
22261                                    else {
22262                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
22263                                    }
22264                            }
22265    
22266                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
22267    
22268                            String sql = query.toString();
22269    
22270                            Session session = null;
22271    
22272                            try {
22273                                    session = openSession();
22274    
22275                                    Query q = session.createQuery(sql);
22276    
22277                                    QueryPos qPos = QueryPos.getInstance(q);
22278    
22279                                    qPos.add(groupId);
22280    
22281                                    if (articleId != null) {
22282                                            qPos.add(articleId);
22283                                    }
22284    
22285                                    qPos.add(status);
22286    
22287                                    count = (Long)q.uniqueResult();
22288    
22289                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
22290                            }
22291                            catch (Exception e) {
22292                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
22293    
22294                                    throw processException(e);
22295                            }
22296                            finally {
22297                                    closeSession(session);
22298                            }
22299                    }
22300    
22301                    return count.intValue();
22302            }
22303    
22304            /**
22305             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
22306             *
22307             * @param groupId the group ID
22308             * @param articleId the article ID
22309             * @param statuses the statuses
22310             * @return the number of matching journal articles
22311             * @throws SystemException if a system exception occurred
22312             */
22313            public int countByG_A_ST(long groupId, String articleId, int[] statuses)
22314                    throws SystemException {
22315                    Object[] finderArgs = new Object[] {
22316                                    groupId, articleId, StringUtil.merge(statuses)
22317                            };
22318    
22319                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
22320                                    finderArgs, this);
22321    
22322                    if (count == null) {
22323                            StringBundler query = new StringBundler();
22324    
22325                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
22326    
22327                            boolean conjunctionable = false;
22328    
22329                            if (conjunctionable) {
22330                                    query.append(WHERE_AND);
22331                            }
22332    
22333                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
22334    
22335                            conjunctionable = true;
22336    
22337                            if (conjunctionable) {
22338                                    query.append(WHERE_AND);
22339                            }
22340    
22341                            if (articleId == null) {
22342                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
22343                            }
22344                            else {
22345                                    if (articleId.equals(StringPool.BLANK)) {
22346                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
22347                                    }
22348                                    else {
22349                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
22350                                    }
22351                            }
22352    
22353                            conjunctionable = true;
22354    
22355                            if ((statuses == null) || (statuses.length > 0)) {
22356                                    if (conjunctionable) {
22357                                            query.append(WHERE_AND);
22358                                    }
22359    
22360                                    query.append(StringPool.OPEN_PARENTHESIS);
22361    
22362                                    for (int i = 0; i < statuses.length; i++) {
22363                                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
22364    
22365                                            if ((i + 1) < statuses.length) {
22366                                                    query.append(WHERE_OR);
22367                                            }
22368                                    }
22369    
22370                                    query.append(StringPool.CLOSE_PARENTHESIS);
22371    
22372                                    conjunctionable = true;
22373                            }
22374    
22375                            String sql = query.toString();
22376    
22377                            Session session = null;
22378    
22379                            try {
22380                                    session = openSession();
22381    
22382                                    Query q = session.createQuery(sql);
22383    
22384                                    QueryPos qPos = QueryPos.getInstance(q);
22385    
22386                                    qPos.add(groupId);
22387    
22388                                    if (articleId != null) {
22389                                            qPos.add(articleId);
22390                                    }
22391    
22392                                    if (statuses != null) {
22393                                            qPos.add(statuses);
22394                                    }
22395    
22396                                    count = (Long)q.uniqueResult();
22397    
22398                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
22399                                            finderArgs, count);
22400                            }
22401                            catch (Exception e) {
22402                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
22403                                            finderArgs);
22404    
22405                                    throw processException(e);
22406                            }
22407                            finally {
22408                                    closeSession(session);
22409                            }
22410                    }
22411    
22412                    return count.intValue();
22413            }
22414    
22415            /**
22416             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
22417             *
22418             * @param groupId the group ID
22419             * @param articleId the article ID
22420             * @param status the status
22421             * @return the number of matching journal articles that the user has permission to view
22422             * @throws SystemException if a system exception occurred
22423             */
22424            public int filterCountByG_A_ST(long groupId, String articleId, int status)
22425                    throws SystemException {
22426                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22427                            return countByG_A_ST(groupId, articleId, status);
22428                    }
22429    
22430                    StringBundler query = new StringBundler(4);
22431    
22432                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
22433    
22434                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
22435    
22436                    if (articleId == null) {
22437                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
22438                    }
22439                    else {
22440                            if (articleId.equals(StringPool.BLANK)) {
22441                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
22442                            }
22443                            else {
22444                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
22445                            }
22446                    }
22447    
22448                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
22449    
22450                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22451                                    JournalArticle.class.getName(),
22452                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22453    
22454                    Session session = null;
22455    
22456                    try {
22457                            session = openSession();
22458    
22459                            SQLQuery q = session.createSQLQuery(sql);
22460    
22461                            q.addScalar(COUNT_COLUMN_NAME,
22462                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
22463    
22464                            QueryPos qPos = QueryPos.getInstance(q);
22465    
22466                            qPos.add(groupId);
22467    
22468                            if (articleId != null) {
22469                                    qPos.add(articleId);
22470                            }
22471    
22472                            qPos.add(status);
22473    
22474                            Long count = (Long)q.uniqueResult();
22475    
22476                            return count.intValue();
22477                    }
22478                    catch (Exception e) {
22479                            throw processException(e);
22480                    }
22481                    finally {
22482                            closeSession(session);
22483                    }
22484            }
22485    
22486            /**
22487             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
22488             *
22489             * @param groupId the group ID
22490             * @param articleId the article ID
22491             * @param statuses the statuses
22492             * @return the number of matching journal articles that the user has permission to view
22493             * @throws SystemException if a system exception occurred
22494             */
22495            public int filterCountByG_A_ST(long groupId, String articleId,
22496                    int[] statuses) throws SystemException {
22497                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22498                            return countByG_A_ST(groupId, articleId, statuses);
22499                    }
22500    
22501                    StringBundler query = new StringBundler();
22502    
22503                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
22504    
22505                    boolean conjunctionable = false;
22506    
22507                    if (conjunctionable) {
22508                            query.append(WHERE_AND);
22509                    }
22510    
22511                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
22512    
22513                    conjunctionable = true;
22514    
22515                    if (conjunctionable) {
22516                            query.append(WHERE_AND);
22517                    }
22518    
22519                    if (articleId == null) {
22520                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
22521                    }
22522                    else {
22523                            if (articleId.equals(StringPool.BLANK)) {
22524                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
22525                            }
22526                            else {
22527                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
22528                            }
22529                    }
22530    
22531                    conjunctionable = true;
22532    
22533                    if ((statuses == null) || (statuses.length > 0)) {
22534                            if (conjunctionable) {
22535                                    query.append(WHERE_AND);
22536                            }
22537    
22538                            query.append(StringPool.OPEN_PARENTHESIS);
22539    
22540                            for (int i = 0; i < statuses.length; i++) {
22541                                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
22542    
22543                                    if ((i + 1) < statuses.length) {
22544                                            query.append(WHERE_OR);
22545                                    }
22546                            }
22547    
22548                            query.append(StringPool.CLOSE_PARENTHESIS);
22549    
22550                            conjunctionable = true;
22551                    }
22552    
22553                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22554                                    JournalArticle.class.getName(),
22555                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22556    
22557                    Session session = null;
22558    
22559                    try {
22560                            session = openSession();
22561    
22562                            SQLQuery q = session.createSQLQuery(sql);
22563    
22564                            q.addScalar(COUNT_COLUMN_NAME,
22565                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
22566    
22567                            QueryPos qPos = QueryPos.getInstance(q);
22568    
22569                            qPos.add(groupId);
22570    
22571                            if (articleId != null) {
22572                                    qPos.add(articleId);
22573                            }
22574    
22575                            if (statuses != null) {
22576                                    qPos.add(statuses);
22577                            }
22578    
22579                            Long count = (Long)q.uniqueResult();
22580    
22581                            return count.intValue();
22582                    }
22583                    catch (Exception e) {
22584                            throw processException(e);
22585                    }
22586                    finally {
22587                            closeSession(session);
22588                    }
22589            }
22590    
22591            private static final String _FINDER_COLUMN_G_A_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
22592            private static final String _FINDER_COLUMN_G_A_ST_GROUPID_5 = "(" +
22593                    _removeConjunction(_FINDER_COLUMN_G_A_ST_GROUPID_2) + ")";
22594            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
22595            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
22596            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = ?) AND ";
22597            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_4 = "(" +
22598                    _removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_1) + ")";
22599            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_5 = "(" +
22600                    _removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_2) + ")";
22601            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_6 = "(" +
22602                    _removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_3) + ")";
22603            private static final String _FINDER_COLUMN_G_A_ST_STATUS_2 = "journalArticle.status = ?";
22604            private static final String _FINDER_COLUMN_G_A_ST_STATUS_5 = "(" +
22605                    _removeConjunction(_FINDER_COLUMN_G_A_ST_STATUS_2) + ")";
22606            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22607                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
22608                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
22609                            "findByG_UT_ST",
22610                            new String[] {
22611                                    Long.class.getName(), String.class.getName(),
22612                                    Integer.class.getName(),
22613                                    
22614                            Integer.class.getName(), Integer.class.getName(),
22615                                    OrderByComparator.class.getName()
22616                            });
22617            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST =
22618                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22619                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
22620                            JournalArticleImpl.class,
22621                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_UT_ST",
22622                            new String[] {
22623                                    Long.class.getName(), String.class.getName(),
22624                                    Integer.class.getName()
22625                            },
22626                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
22627                            JournalArticleModelImpl.URLTITLE_COLUMN_BITMASK |
22628                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
22629                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
22630                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
22631            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22632                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
22633                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT_ST",
22634                            new String[] {
22635                                    Long.class.getName(), String.class.getName(),
22636                                    Integer.class.getName()
22637                            });
22638    
22639            /**
22640             * Returns all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
22641             *
22642             * @param groupId the group ID
22643             * @param urlTitle the url title
22644             * @param status the status
22645             * @return the matching journal articles
22646             * @throws SystemException if a system exception occurred
22647             */
22648            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
22649                    int status) throws SystemException {
22650                    return findByG_UT_ST(groupId, urlTitle, status, QueryUtil.ALL_POS,
22651                            QueryUtil.ALL_POS, null);
22652            }
22653    
22654            /**
22655             * Returns a range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
22656             *
22657             * <p>
22658             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22659             * </p>
22660             *
22661             * @param groupId the group ID
22662             * @param urlTitle the url title
22663             * @param status the status
22664             * @param start the lower bound of the range of journal articles
22665             * @param end the upper bound of the range of journal articles (not inclusive)
22666             * @return the range of matching journal articles
22667             * @throws SystemException if a system exception occurred
22668             */
22669            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
22670                    int status, int start, int end) throws SystemException {
22671                    return findByG_UT_ST(groupId, urlTitle, status, start, end, null);
22672            }
22673    
22674            /**
22675             * Returns an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
22676             *
22677             * <p>
22678             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22679             * </p>
22680             *
22681             * @param groupId the group ID
22682             * @param urlTitle the url title
22683             * @param status the status
22684             * @param start the lower bound of the range of journal articles
22685             * @param end the upper bound of the range of journal articles (not inclusive)
22686             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
22687             * @return the ordered range of matching journal articles
22688             * @throws SystemException if a system exception occurred
22689             */
22690            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
22691                    int status, int start, int end, OrderByComparator orderByComparator)
22692                    throws SystemException {
22693                    boolean pagination = true;
22694                    FinderPath finderPath = null;
22695                    Object[] finderArgs = null;
22696    
22697                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
22698                                    (orderByComparator == null)) {
22699                            pagination = false;
22700                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST;
22701                            finderArgs = new Object[] { groupId, urlTitle, status };
22702                    }
22703                    else {
22704                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT_ST;
22705                            finderArgs = new Object[] {
22706                                            groupId, urlTitle, status,
22707                                            
22708                                            start, end, orderByComparator
22709                                    };
22710                    }
22711    
22712                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
22713                                    finderArgs, this);
22714    
22715                    if ((list != null) && !list.isEmpty()) {
22716                            for (JournalArticle journalArticle : list) {
22717                                    if ((groupId != journalArticle.getGroupId()) ||
22718                                                    !Validator.equals(urlTitle, journalArticle.getUrlTitle()) ||
22719                                                    (status != journalArticle.getStatus())) {
22720                                            list = null;
22721    
22722                                            break;
22723                                    }
22724                            }
22725                    }
22726    
22727                    if (list == null) {
22728                            StringBundler query = null;
22729    
22730                            if (orderByComparator != null) {
22731                                    query = new StringBundler(5 +
22732                                                    (orderByComparator.getOrderByFields().length * 3));
22733                            }
22734                            else {
22735                                    query = new StringBundler(5);
22736                            }
22737    
22738                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
22739    
22740                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
22741    
22742                            if (urlTitle == null) {
22743                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
22744                            }
22745                            else {
22746                                    if (urlTitle.equals(StringPool.BLANK)) {
22747                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
22748                                    }
22749                                    else {
22750                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
22751                                    }
22752                            }
22753    
22754                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
22755    
22756                            if (orderByComparator != null) {
22757                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
22758                                            orderByComparator);
22759                            }
22760                            else
22761                             if (pagination) {
22762                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22763                            }
22764    
22765                            String sql = query.toString();
22766    
22767                            Session session = null;
22768    
22769                            try {
22770                                    session = openSession();
22771    
22772                                    Query q = session.createQuery(sql);
22773    
22774                                    QueryPos qPos = QueryPos.getInstance(q);
22775    
22776                                    qPos.add(groupId);
22777    
22778                                    if (urlTitle != null) {
22779                                            qPos.add(urlTitle);
22780                                    }
22781    
22782                                    qPos.add(status);
22783    
22784                                    if (!pagination) {
22785                                            list = (List<JournalArticle>)QueryUtil.list(q,
22786                                                            getDialect(), start, end, false);
22787    
22788                                            Collections.sort(list);
22789    
22790                                            list = new UnmodifiableList<JournalArticle>(list);
22791                                    }
22792                                    else {
22793                                            list = (List<JournalArticle>)QueryUtil.list(q,
22794                                                            getDialect(), start, end);
22795                                    }
22796    
22797                                    cacheResult(list);
22798    
22799                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
22800                            }
22801                            catch (Exception e) {
22802                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
22803    
22804                                    throw processException(e);
22805                            }
22806                            finally {
22807                                    closeSession(session);
22808                            }
22809                    }
22810    
22811                    return list;
22812            }
22813    
22814            /**
22815             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
22816             *
22817             * @param groupId the group ID
22818             * @param urlTitle the url title
22819             * @param status the status
22820             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22821             * @return the first matching journal article
22822             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
22823             * @throws SystemException if a system exception occurred
22824             */
22825            public JournalArticle findByG_UT_ST_First(long groupId, String urlTitle,
22826                    int status, OrderByComparator orderByComparator)
22827                    throws NoSuchArticleException, SystemException {
22828                    JournalArticle journalArticle = fetchByG_UT_ST_First(groupId, urlTitle,
22829                                    status, orderByComparator);
22830    
22831                    if (journalArticle != null) {
22832                            return journalArticle;
22833                    }
22834    
22835                    StringBundler msg = new StringBundler(8);
22836    
22837                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
22838    
22839                    msg.append("groupId=");
22840                    msg.append(groupId);
22841    
22842                    msg.append(", urlTitle=");
22843                    msg.append(urlTitle);
22844    
22845                    msg.append(", status=");
22846                    msg.append(status);
22847    
22848                    msg.append(StringPool.CLOSE_CURLY_BRACE);
22849    
22850                    throw new NoSuchArticleException(msg.toString());
22851            }
22852    
22853            /**
22854             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
22855             *
22856             * @param groupId the group ID
22857             * @param urlTitle the url title
22858             * @param status the status
22859             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22860             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
22861             * @throws SystemException if a system exception occurred
22862             */
22863            public JournalArticle fetchByG_UT_ST_First(long groupId, String urlTitle,
22864                    int status, OrderByComparator orderByComparator)
22865                    throws SystemException {
22866                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status, 0,
22867                                    1, orderByComparator);
22868    
22869                    if (!list.isEmpty()) {
22870                            return list.get(0);
22871                    }
22872    
22873                    return null;
22874            }
22875    
22876            /**
22877             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
22878             *
22879             * @param groupId the group ID
22880             * @param urlTitle the url title
22881             * @param status the status
22882             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22883             * @return the last matching journal article
22884             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
22885             * @throws SystemException if a system exception occurred
22886             */
22887            public JournalArticle findByG_UT_ST_Last(long groupId, String urlTitle,
22888                    int status, OrderByComparator orderByComparator)
22889                    throws NoSuchArticleException, SystemException {
22890                    JournalArticle journalArticle = fetchByG_UT_ST_Last(groupId, urlTitle,
22891                                    status, orderByComparator);
22892    
22893                    if (journalArticle != null) {
22894                            return journalArticle;
22895                    }
22896    
22897                    StringBundler msg = new StringBundler(8);
22898    
22899                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
22900    
22901                    msg.append("groupId=");
22902                    msg.append(groupId);
22903    
22904                    msg.append(", urlTitle=");
22905                    msg.append(urlTitle);
22906    
22907                    msg.append(", status=");
22908                    msg.append(status);
22909    
22910                    msg.append(StringPool.CLOSE_CURLY_BRACE);
22911    
22912                    throw new NoSuchArticleException(msg.toString());
22913            }
22914    
22915            /**
22916             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
22917             *
22918             * @param groupId the group ID
22919             * @param urlTitle the url title
22920             * @param status the status
22921             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22922             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
22923             * @throws SystemException if a system exception occurred
22924             */
22925            public JournalArticle fetchByG_UT_ST_Last(long groupId, String urlTitle,
22926                    int status, OrderByComparator orderByComparator)
22927                    throws SystemException {
22928                    int count = countByG_UT_ST(groupId, urlTitle, status);
22929    
22930                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status,
22931                                    count - 1, count, orderByComparator);
22932    
22933                    if (!list.isEmpty()) {
22934                            return list.get(0);
22935                    }
22936    
22937                    return null;
22938            }
22939    
22940            /**
22941             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
22942             *
22943             * @param id the primary key of the current journal article
22944             * @param groupId the group ID
22945             * @param urlTitle the url title
22946             * @param status the status
22947             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22948             * @return the previous, current, and next journal article
22949             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
22950             * @throws SystemException if a system exception occurred
22951             */
22952            public JournalArticle[] findByG_UT_ST_PrevAndNext(long id, long groupId,
22953                    String urlTitle, int status, OrderByComparator orderByComparator)
22954                    throws NoSuchArticleException, SystemException {
22955                    JournalArticle journalArticle = findByPrimaryKey(id);
22956    
22957                    Session session = null;
22958    
22959                    try {
22960                            session = openSession();
22961    
22962                            JournalArticle[] array = new JournalArticleImpl[3];
22963    
22964                            array[0] = getByG_UT_ST_PrevAndNext(session, journalArticle,
22965                                            groupId, urlTitle, status, orderByComparator, true);
22966    
22967                            array[1] = journalArticle;
22968    
22969                            array[2] = getByG_UT_ST_PrevAndNext(session, journalArticle,
22970                                            groupId, urlTitle, status, orderByComparator, false);
22971    
22972                            return array;
22973                    }
22974                    catch (Exception e) {
22975                            throw processException(e);
22976                    }
22977                    finally {
22978                            closeSession(session);
22979                    }
22980            }
22981    
22982            protected JournalArticle getByG_UT_ST_PrevAndNext(Session session,
22983                    JournalArticle journalArticle, long groupId, String urlTitle,
22984                    int status, OrderByComparator orderByComparator, boolean previous) {
22985                    StringBundler query = null;
22986    
22987                    if (orderByComparator != null) {
22988                            query = new StringBundler(6 +
22989                                            (orderByComparator.getOrderByFields().length * 6));
22990                    }
22991                    else {
22992                            query = new StringBundler(3);
22993                    }
22994    
22995                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
22996    
22997                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
22998    
22999                    if (urlTitle == null) {
23000                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
23001                    }
23002                    else {
23003                            if (urlTitle.equals(StringPool.BLANK)) {
23004                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
23005                            }
23006                            else {
23007                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
23008                            }
23009                    }
23010    
23011                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
23012    
23013                    if (orderByComparator != null) {
23014                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
23015    
23016                            if (orderByConditionFields.length > 0) {
23017                                    query.append(WHERE_AND);
23018                            }
23019    
23020                            for (int i = 0; i < orderByConditionFields.length; i++) {
23021                                    query.append(_ORDER_BY_ENTITY_ALIAS);
23022                                    query.append(orderByConditionFields[i]);
23023    
23024                                    if ((i + 1) < orderByConditionFields.length) {
23025                                            if (orderByComparator.isAscending() ^ previous) {
23026                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
23027                                            }
23028                                            else {
23029                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
23030                                            }
23031                                    }
23032                                    else {
23033                                            if (orderByComparator.isAscending() ^ previous) {
23034                                                    query.append(WHERE_GREATER_THAN);
23035                                            }
23036                                            else {
23037                                                    query.append(WHERE_LESSER_THAN);
23038                                            }
23039                                    }
23040                            }
23041    
23042                            query.append(ORDER_BY_CLAUSE);
23043    
23044                            String[] orderByFields = orderByComparator.getOrderByFields();
23045    
23046                            for (int i = 0; i < orderByFields.length; i++) {
23047                                    query.append(_ORDER_BY_ENTITY_ALIAS);
23048                                    query.append(orderByFields[i]);
23049    
23050                                    if ((i + 1) < orderByFields.length) {
23051                                            if (orderByComparator.isAscending() ^ previous) {
23052                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
23053                                            }
23054                                            else {
23055                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
23056                                            }
23057                                    }
23058                                    else {
23059                                            if (orderByComparator.isAscending() ^ previous) {
23060                                                    query.append(ORDER_BY_ASC);
23061                                            }
23062                                            else {
23063                                                    query.append(ORDER_BY_DESC);
23064                                            }
23065                                    }
23066                            }
23067                    }
23068                    else {
23069                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23070                    }
23071    
23072                    String sql = query.toString();
23073    
23074                    Query q = session.createQuery(sql);
23075    
23076                    q.setFirstResult(0);
23077                    q.setMaxResults(2);
23078    
23079                    QueryPos qPos = QueryPos.getInstance(q);
23080    
23081                    qPos.add(groupId);
23082    
23083                    if (urlTitle != null) {
23084                            qPos.add(urlTitle);
23085                    }
23086    
23087                    qPos.add(status);
23088    
23089                    if (orderByComparator != null) {
23090                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
23091    
23092                            for (Object value : values) {
23093                                    qPos.add(value);
23094                            }
23095                    }
23096    
23097                    List<JournalArticle> list = q.list();
23098    
23099                    if (list.size() == 2) {
23100                            return list.get(1);
23101                    }
23102                    else {
23103                            return null;
23104                    }
23105            }
23106    
23107            /**
23108             * Returns all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
23109             *
23110             * @param groupId the group ID
23111             * @param urlTitle the url title
23112             * @param status the status
23113             * @return the matching journal articles that the user has permission to view
23114             * @throws SystemException if a system exception occurred
23115             */
23116            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
23117                    String urlTitle, int status) throws SystemException {
23118                    return filterFindByG_UT_ST(groupId, urlTitle, status,
23119                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
23120            }
23121    
23122            /**
23123             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
23124             *
23125             * <p>
23126             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23127             * </p>
23128             *
23129             * @param groupId the group ID
23130             * @param urlTitle the url title
23131             * @param status the status
23132             * @param start the lower bound of the range of journal articles
23133             * @param end the upper bound of the range of journal articles (not inclusive)
23134             * @return the range of matching journal articles that the user has permission to view
23135             * @throws SystemException if a system exception occurred
23136             */
23137            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
23138                    String urlTitle, int status, int start, int end)
23139                    throws SystemException {
23140                    return filterFindByG_UT_ST(groupId, urlTitle, status, start, end, null);
23141            }
23142    
23143            /**
23144             * 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;.
23145             *
23146             * <p>
23147             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23148             * </p>
23149             *
23150             * @param groupId the group ID
23151             * @param urlTitle the url title
23152             * @param status the status
23153             * @param start the lower bound of the range of journal articles
23154             * @param end the upper bound of the range of journal articles (not inclusive)
23155             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
23156             * @return the ordered range of matching journal articles that the user has permission to view
23157             * @throws SystemException if a system exception occurred
23158             */
23159            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
23160                    String urlTitle, int status, int start, int end,
23161                    OrderByComparator orderByComparator) throws SystemException {
23162                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23163                            return findByG_UT_ST(groupId, urlTitle, status, start, end,
23164                                    orderByComparator);
23165                    }
23166    
23167                    StringBundler query = null;
23168    
23169                    if (orderByComparator != null) {
23170                            query = new StringBundler(5 +
23171                                            (orderByComparator.getOrderByFields().length * 3));
23172                    }
23173                    else {
23174                            query = new StringBundler(5);
23175                    }
23176    
23177                    if (getDB().isSupportsInlineDistinct()) {
23178                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
23179                    }
23180                    else {
23181                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
23182                    }
23183    
23184                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
23185    
23186                    if (urlTitle == null) {
23187                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
23188                    }
23189                    else {
23190                            if (urlTitle.equals(StringPool.BLANK)) {
23191                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
23192                            }
23193                            else {
23194                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
23195                            }
23196                    }
23197    
23198                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
23199    
23200                    if (!getDB().isSupportsInlineDistinct()) {
23201                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
23202                    }
23203    
23204                    if (orderByComparator != null) {
23205                            if (getDB().isSupportsInlineDistinct()) {
23206                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
23207                                            orderByComparator);
23208                            }
23209                            else {
23210                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
23211                                            orderByComparator);
23212                            }
23213                    }
23214                    else {
23215                            if (getDB().isSupportsInlineDistinct()) {
23216                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23217                            }
23218                            else {
23219                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
23220                            }
23221                    }
23222    
23223                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23224                                    JournalArticle.class.getName(),
23225                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23226    
23227                    Session session = null;
23228    
23229                    try {
23230                            session = openSession();
23231    
23232                            SQLQuery q = session.createSQLQuery(sql);
23233    
23234                            if (getDB().isSupportsInlineDistinct()) {
23235                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
23236                            }
23237                            else {
23238                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
23239                            }
23240    
23241                            QueryPos qPos = QueryPos.getInstance(q);
23242    
23243                            qPos.add(groupId);
23244    
23245                            if (urlTitle != null) {
23246                                    qPos.add(urlTitle);
23247                            }
23248    
23249                            qPos.add(status);
23250    
23251                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
23252                                    end);
23253                    }
23254                    catch (Exception e) {
23255                            throw processException(e);
23256                    }
23257                    finally {
23258                            closeSession(session);
23259                    }
23260            }
23261    
23262            /**
23263             * 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;.
23264             *
23265             * @param id the primary key of the current journal article
23266             * @param groupId the group ID
23267             * @param urlTitle the url title
23268             * @param status the status
23269             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23270             * @return the previous, current, and next journal article
23271             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
23272             * @throws SystemException if a system exception occurred
23273             */
23274            public JournalArticle[] filterFindByG_UT_ST_PrevAndNext(long id,
23275                    long groupId, String urlTitle, int status,
23276                    OrderByComparator orderByComparator)
23277                    throws NoSuchArticleException, SystemException {
23278                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23279                            return findByG_UT_ST_PrevAndNext(id, groupId, urlTitle, status,
23280                                    orderByComparator);
23281                    }
23282    
23283                    JournalArticle journalArticle = findByPrimaryKey(id);
23284    
23285                    Session session = null;
23286    
23287                    try {
23288                            session = openSession();
23289    
23290                            JournalArticle[] array = new JournalArticleImpl[3];
23291    
23292                            array[0] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
23293                                            groupId, urlTitle, status, orderByComparator, true);
23294    
23295                            array[1] = journalArticle;
23296    
23297                            array[2] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
23298                                            groupId, urlTitle, status, orderByComparator, false);
23299    
23300                            return array;
23301                    }
23302                    catch (Exception e) {
23303                            throw processException(e);
23304                    }
23305                    finally {
23306                            closeSession(session);
23307                    }
23308            }
23309    
23310            protected JournalArticle filterGetByG_UT_ST_PrevAndNext(Session session,
23311                    JournalArticle journalArticle, long groupId, String urlTitle,
23312                    int status, OrderByComparator orderByComparator, boolean previous) {
23313                    StringBundler query = null;
23314    
23315                    if (orderByComparator != null) {
23316                            query = new StringBundler(6 +
23317                                            (orderByComparator.getOrderByFields().length * 6));
23318                    }
23319                    else {
23320                            query = new StringBundler(3);
23321                    }
23322    
23323                    if (getDB().isSupportsInlineDistinct()) {
23324                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
23325                    }
23326                    else {
23327                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
23328                    }
23329    
23330                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
23331    
23332                    if (urlTitle == null) {
23333                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
23334                    }
23335                    else {
23336                            if (urlTitle.equals(StringPool.BLANK)) {
23337                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
23338                            }
23339                            else {
23340                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
23341                            }
23342                    }
23343    
23344                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
23345    
23346                    if (!getDB().isSupportsInlineDistinct()) {
23347                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
23348                    }
23349    
23350                    if (orderByComparator != null) {
23351                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
23352    
23353                            if (orderByConditionFields.length > 0) {
23354                                    query.append(WHERE_AND);
23355                            }
23356    
23357                            for (int i = 0; i < orderByConditionFields.length; i++) {
23358                                    if (getDB().isSupportsInlineDistinct()) {
23359                                            query.append(_ORDER_BY_ENTITY_ALIAS);
23360                                    }
23361                                    else {
23362                                            query.append(_ORDER_BY_ENTITY_TABLE);
23363                                    }
23364    
23365                                    query.append(orderByConditionFields[i]);
23366    
23367                                    if ((i + 1) < orderByConditionFields.length) {
23368                                            if (orderByComparator.isAscending() ^ previous) {
23369                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
23370                                            }
23371                                            else {
23372                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
23373                                            }
23374                                    }
23375                                    else {
23376                                            if (orderByComparator.isAscending() ^ previous) {
23377                                                    query.append(WHERE_GREATER_THAN);
23378                                            }
23379                                            else {
23380                                                    query.append(WHERE_LESSER_THAN);
23381                                            }
23382                                    }
23383                            }
23384    
23385                            query.append(ORDER_BY_CLAUSE);
23386    
23387                            String[] orderByFields = orderByComparator.getOrderByFields();
23388    
23389                            for (int i = 0; i < orderByFields.length; i++) {
23390                                    if (getDB().isSupportsInlineDistinct()) {
23391                                            query.append(_ORDER_BY_ENTITY_ALIAS);
23392                                    }
23393                                    else {
23394                                            query.append(_ORDER_BY_ENTITY_TABLE);
23395                                    }
23396    
23397                                    query.append(orderByFields[i]);
23398    
23399                                    if ((i + 1) < orderByFields.length) {
23400                                            if (orderByComparator.isAscending() ^ previous) {
23401                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
23402                                            }
23403                                            else {
23404                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
23405                                            }
23406                                    }
23407                                    else {
23408                                            if (orderByComparator.isAscending() ^ previous) {
23409                                                    query.append(ORDER_BY_ASC);
23410                                            }
23411                                            else {
23412                                                    query.append(ORDER_BY_DESC);
23413                                            }
23414                                    }
23415                            }
23416                    }
23417                    else {
23418                            if (getDB().isSupportsInlineDistinct()) {
23419                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23420                            }
23421                            else {
23422                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
23423                            }
23424                    }
23425    
23426                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23427                                    JournalArticle.class.getName(),
23428                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23429    
23430                    SQLQuery q = session.createSQLQuery(sql);
23431    
23432                    q.setFirstResult(0);
23433                    q.setMaxResults(2);
23434    
23435                    if (getDB().isSupportsInlineDistinct()) {
23436                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
23437                    }
23438                    else {
23439                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
23440                    }
23441    
23442                    QueryPos qPos = QueryPos.getInstance(q);
23443    
23444                    qPos.add(groupId);
23445    
23446                    if (urlTitle != null) {
23447                            qPos.add(urlTitle);
23448                    }
23449    
23450                    qPos.add(status);
23451    
23452                    if (orderByComparator != null) {
23453                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
23454    
23455                            for (Object value : values) {
23456                                    qPos.add(value);
23457                            }
23458                    }
23459    
23460                    List<JournalArticle> list = q.list();
23461    
23462                    if (list.size() == 2) {
23463                            return list.get(1);
23464                    }
23465                    else {
23466                            return null;
23467                    }
23468            }
23469    
23470            /**
23471             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63; from the database.
23472             *
23473             * @param groupId the group ID
23474             * @param urlTitle the url title
23475             * @param status the status
23476             * @throws SystemException if a system exception occurred
23477             */
23478            public void removeByG_UT_ST(long groupId, String urlTitle, int status)
23479                    throws SystemException {
23480                    for (JournalArticle journalArticle : findByG_UT_ST(groupId, urlTitle,
23481                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
23482                            remove(journalArticle);
23483                    }
23484            }
23485    
23486            /**
23487             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
23488             *
23489             * @param groupId the group ID
23490             * @param urlTitle the url title
23491             * @param status the status
23492             * @return the number of matching journal articles
23493             * @throws SystemException if a system exception occurred
23494             */
23495            public int countByG_UT_ST(long groupId, String urlTitle, int status)
23496                    throws SystemException {
23497                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_UT_ST;
23498    
23499                    Object[] finderArgs = new Object[] { groupId, urlTitle, status };
23500    
23501                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
23502                                    this);
23503    
23504                    if (count == null) {
23505                            StringBundler query = new StringBundler(4);
23506    
23507                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
23508    
23509                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
23510    
23511                            if (urlTitle == null) {
23512                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
23513                            }
23514                            else {
23515                                    if (urlTitle.equals(StringPool.BLANK)) {
23516                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
23517                                    }
23518                                    else {
23519                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
23520                                    }
23521                            }
23522    
23523                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
23524    
23525                            String sql = query.toString();
23526    
23527                            Session session = null;
23528    
23529                            try {
23530                                    session = openSession();
23531    
23532                                    Query q = session.createQuery(sql);
23533    
23534                                    QueryPos qPos = QueryPos.getInstance(q);
23535    
23536                                    qPos.add(groupId);
23537    
23538                                    if (urlTitle != null) {
23539                                            qPos.add(urlTitle);
23540                                    }
23541    
23542                                    qPos.add(status);
23543    
23544                                    count = (Long)q.uniqueResult();
23545    
23546                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
23547                            }
23548                            catch (Exception e) {
23549                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
23550    
23551                                    throw processException(e);
23552                            }
23553                            finally {
23554                                    closeSession(session);
23555                            }
23556                    }
23557    
23558                    return count.intValue();
23559            }
23560    
23561            /**
23562             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
23563             *
23564             * @param groupId the group ID
23565             * @param urlTitle the url title
23566             * @param status the status
23567             * @return the number of matching journal articles that the user has permission to view
23568             * @throws SystemException if a system exception occurred
23569             */
23570            public int filterCountByG_UT_ST(long groupId, String urlTitle, int status)
23571                    throws SystemException {
23572                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23573                            return countByG_UT_ST(groupId, urlTitle, status);
23574                    }
23575    
23576                    StringBundler query = new StringBundler(4);
23577    
23578                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
23579    
23580                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
23581    
23582                    if (urlTitle == null) {
23583                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
23584                    }
23585                    else {
23586                            if (urlTitle.equals(StringPool.BLANK)) {
23587                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
23588                            }
23589                            else {
23590                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
23591                            }
23592                    }
23593    
23594                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
23595    
23596                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23597                                    JournalArticle.class.getName(),
23598                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23599    
23600                    Session session = null;
23601    
23602                    try {
23603                            session = openSession();
23604    
23605                            SQLQuery q = session.createSQLQuery(sql);
23606    
23607                            q.addScalar(COUNT_COLUMN_NAME,
23608                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
23609    
23610                            QueryPos qPos = QueryPos.getInstance(q);
23611    
23612                            qPos.add(groupId);
23613    
23614                            if (urlTitle != null) {
23615                                    qPos.add(urlTitle);
23616                            }
23617    
23618                            qPos.add(status);
23619    
23620                            Long count = (Long)q.uniqueResult();
23621    
23622                            return count.intValue();
23623                    }
23624                    catch (Exception e) {
23625                            throw processException(e);
23626                    }
23627                    finally {
23628                            closeSession(session);
23629                    }
23630            }
23631    
23632            private static final String _FINDER_COLUMN_G_UT_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
23633            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_1 = "journalArticle.urlTitle IS NULL AND ";
23634            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_2 = "journalArticle.urlTitle = ? AND ";
23635            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = ?) AND ";
23636            private static final String _FINDER_COLUMN_G_UT_ST_STATUS_2 = "journalArticle.status = ?";
23637            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23638                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
23639                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
23640                            "findByC_V_ST",
23641                            new String[] {
23642                                    Long.class.getName(), Double.class.getName(),
23643                                    Integer.class.getName(),
23644                                    
23645                            Integer.class.getName(), Integer.class.getName(),
23646                                    OrderByComparator.class.getName()
23647                            });
23648            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST =
23649                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23650                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
23651                            JournalArticleImpl.class,
23652                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_V_ST",
23653                            new String[] {
23654                                    Long.class.getName(), Double.class.getName(),
23655                                    Integer.class.getName()
23656                            },
23657                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
23658                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK |
23659                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
23660                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK);
23661            public static final FinderPath FINDER_PATH_COUNT_BY_C_V_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23662                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
23663                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_V_ST",
23664                            new String[] {
23665                                    Long.class.getName(), Double.class.getName(),
23666                                    Integer.class.getName()
23667                            });
23668    
23669            /**
23670             * Returns all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
23671             *
23672             * @param companyId the company ID
23673             * @param version the version
23674             * @param status the status
23675             * @return the matching journal articles
23676             * @throws SystemException if a system exception occurred
23677             */
23678            public List<JournalArticle> findByC_V_ST(long companyId, double version,
23679                    int status) throws SystemException {
23680                    return findByC_V_ST(companyId, version, status, QueryUtil.ALL_POS,
23681                            QueryUtil.ALL_POS, null);
23682            }
23683    
23684            /**
23685             * Returns a range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
23686             *
23687             * <p>
23688             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23689             * </p>
23690             *
23691             * @param companyId the company ID
23692             * @param version the version
23693             * @param status the status
23694             * @param start the lower bound of the range of journal articles
23695             * @param end the upper bound of the range of journal articles (not inclusive)
23696             * @return the range of matching journal articles
23697             * @throws SystemException if a system exception occurred
23698             */
23699            public List<JournalArticle> findByC_V_ST(long companyId, double version,
23700                    int status, int start, int end) throws SystemException {
23701                    return findByC_V_ST(companyId, version, status, start, end, null);
23702            }
23703    
23704            /**
23705             * Returns an ordered range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
23706             *
23707             * <p>
23708             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23709             * </p>
23710             *
23711             * @param companyId the company ID
23712             * @param version the version
23713             * @param status the status
23714             * @param start the lower bound of the range of journal articles
23715             * @param end the upper bound of the range of journal articles (not inclusive)
23716             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
23717             * @return the ordered range of matching journal articles
23718             * @throws SystemException if a system exception occurred
23719             */
23720            public List<JournalArticle> findByC_V_ST(long companyId, double version,
23721                    int status, int start, int end, OrderByComparator orderByComparator)
23722                    throws SystemException {
23723                    boolean pagination = true;
23724                    FinderPath finderPath = null;
23725                    Object[] finderArgs = null;
23726    
23727                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
23728                                    (orderByComparator == null)) {
23729                            pagination = false;
23730                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST;
23731                            finderArgs = new Object[] { companyId, version, status };
23732                    }
23733                    else {
23734                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V_ST;
23735                            finderArgs = new Object[] {
23736                                            companyId, version, status,
23737                                            
23738                                            start, end, orderByComparator
23739                                    };
23740                    }
23741    
23742                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
23743                                    finderArgs, this);
23744    
23745                    if ((list != null) && !list.isEmpty()) {
23746                            for (JournalArticle journalArticle : list) {
23747                                    if ((companyId != journalArticle.getCompanyId()) ||
23748                                                    (version != journalArticle.getVersion()) ||
23749                                                    (status != journalArticle.getStatus())) {
23750                                            list = null;
23751    
23752                                            break;
23753                                    }
23754                            }
23755                    }
23756    
23757                    if (list == null) {
23758                            StringBundler query = null;
23759    
23760                            if (orderByComparator != null) {
23761                                    query = new StringBundler(5 +
23762                                                    (orderByComparator.getOrderByFields().length * 3));
23763                            }
23764                            else {
23765                                    query = new StringBundler(5);
23766                            }
23767    
23768                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
23769    
23770                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
23771    
23772                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
23773    
23774                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
23775    
23776                            if (orderByComparator != null) {
23777                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
23778                                            orderByComparator);
23779                            }
23780                            else
23781                             if (pagination) {
23782                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23783                            }
23784    
23785                            String sql = query.toString();
23786    
23787                            Session session = null;
23788    
23789                            try {
23790                                    session = openSession();
23791    
23792                                    Query q = session.createQuery(sql);
23793    
23794                                    QueryPos qPos = QueryPos.getInstance(q);
23795    
23796                                    qPos.add(companyId);
23797    
23798                                    qPos.add(version);
23799    
23800                                    qPos.add(status);
23801    
23802                                    if (!pagination) {
23803                                            list = (List<JournalArticle>)QueryUtil.list(q,
23804                                                            getDialect(), start, end, false);
23805    
23806                                            Collections.sort(list);
23807    
23808                                            list = new UnmodifiableList<JournalArticle>(list);
23809                                    }
23810                                    else {
23811                                            list = (List<JournalArticle>)QueryUtil.list(q,
23812                                                            getDialect(), start, end);
23813                                    }
23814    
23815                                    cacheResult(list);
23816    
23817                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
23818                            }
23819                            catch (Exception e) {
23820                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
23821    
23822                                    throw processException(e);
23823                            }
23824                            finally {
23825                                    closeSession(session);
23826                            }
23827                    }
23828    
23829                    return list;
23830            }
23831    
23832            /**
23833             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
23834             *
23835             * @param companyId the company ID
23836             * @param version the version
23837             * @param status the status
23838             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23839             * @return the first matching journal article
23840             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
23841             * @throws SystemException if a system exception occurred
23842             */
23843            public JournalArticle findByC_V_ST_First(long companyId, double version,
23844                    int status, OrderByComparator orderByComparator)
23845                    throws NoSuchArticleException, SystemException {
23846                    JournalArticle journalArticle = fetchByC_V_ST_First(companyId, version,
23847                                    status, orderByComparator);
23848    
23849                    if (journalArticle != null) {
23850                            return journalArticle;
23851                    }
23852    
23853                    StringBundler msg = new StringBundler(8);
23854    
23855                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
23856    
23857                    msg.append("companyId=");
23858                    msg.append(companyId);
23859    
23860                    msg.append(", version=");
23861                    msg.append(version);
23862    
23863                    msg.append(", status=");
23864                    msg.append(status);
23865    
23866                    msg.append(StringPool.CLOSE_CURLY_BRACE);
23867    
23868                    throw new NoSuchArticleException(msg.toString());
23869            }
23870    
23871            /**
23872             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
23873             *
23874             * @param companyId the company ID
23875             * @param version the version
23876             * @param status the status
23877             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23878             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
23879             * @throws SystemException if a system exception occurred
23880             */
23881            public JournalArticle fetchByC_V_ST_First(long companyId, double version,
23882                    int status, OrderByComparator orderByComparator)
23883                    throws SystemException {
23884                    List<JournalArticle> list = findByC_V_ST(companyId, version, status, 0,
23885                                    1, orderByComparator);
23886    
23887                    if (!list.isEmpty()) {
23888                            return list.get(0);
23889                    }
23890    
23891                    return null;
23892            }
23893    
23894            /**
23895             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
23896             *
23897             * @param companyId the company ID
23898             * @param version the version
23899             * @param status the status
23900             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23901             * @return the last matching journal article
23902             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
23903             * @throws SystemException if a system exception occurred
23904             */
23905            public JournalArticle findByC_V_ST_Last(long companyId, double version,
23906                    int status, OrderByComparator orderByComparator)
23907                    throws NoSuchArticleException, SystemException {
23908                    JournalArticle journalArticle = fetchByC_V_ST_Last(companyId, version,
23909                                    status, orderByComparator);
23910    
23911                    if (journalArticle != null) {
23912                            return journalArticle;
23913                    }
23914    
23915                    StringBundler msg = new StringBundler(8);
23916    
23917                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
23918    
23919                    msg.append("companyId=");
23920                    msg.append(companyId);
23921    
23922                    msg.append(", version=");
23923                    msg.append(version);
23924    
23925                    msg.append(", status=");
23926                    msg.append(status);
23927    
23928                    msg.append(StringPool.CLOSE_CURLY_BRACE);
23929    
23930                    throw new NoSuchArticleException(msg.toString());
23931            }
23932    
23933            /**
23934             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
23935             *
23936             * @param companyId the company ID
23937             * @param version the version
23938             * @param status the status
23939             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23940             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
23941             * @throws SystemException if a system exception occurred
23942             */
23943            public JournalArticle fetchByC_V_ST_Last(long companyId, double version,
23944                    int status, OrderByComparator orderByComparator)
23945                    throws SystemException {
23946                    int count = countByC_V_ST(companyId, version, status);
23947    
23948                    List<JournalArticle> list = findByC_V_ST(companyId, version, status,
23949                                    count - 1, count, orderByComparator);
23950    
23951                    if (!list.isEmpty()) {
23952                            return list.get(0);
23953                    }
23954    
23955                    return null;
23956            }
23957    
23958            /**
23959             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
23960             *
23961             * @param id the primary key of the current journal article
23962             * @param companyId the company ID
23963             * @param version the version
23964             * @param status the status
23965             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23966             * @return the previous, current, and next journal article
23967             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
23968             * @throws SystemException if a system exception occurred
23969             */
23970            public JournalArticle[] findByC_V_ST_PrevAndNext(long id, long companyId,
23971                    double version, int status, OrderByComparator orderByComparator)
23972                    throws NoSuchArticleException, SystemException {
23973                    JournalArticle journalArticle = findByPrimaryKey(id);
23974    
23975                    Session session = null;
23976    
23977                    try {
23978                            session = openSession();
23979    
23980                            JournalArticle[] array = new JournalArticleImpl[3];
23981    
23982                            array[0] = getByC_V_ST_PrevAndNext(session, journalArticle,
23983                                            companyId, version, status, orderByComparator, true);
23984    
23985                            array[1] = journalArticle;
23986    
23987                            array[2] = getByC_V_ST_PrevAndNext(session, journalArticle,
23988                                            companyId, version, status, orderByComparator, false);
23989    
23990                            return array;
23991                    }
23992                    catch (Exception e) {
23993                            throw processException(e);
23994                    }
23995                    finally {
23996                            closeSession(session);
23997                    }
23998            }
23999    
24000            protected JournalArticle getByC_V_ST_PrevAndNext(Session session,
24001                    JournalArticle journalArticle, long companyId, double version,
24002                    int status, OrderByComparator orderByComparator, boolean previous) {
24003                    StringBundler query = null;
24004    
24005                    if (orderByComparator != null) {
24006                            query = new StringBundler(6 +
24007                                            (orderByComparator.getOrderByFields().length * 6));
24008                    }
24009                    else {
24010                            query = new StringBundler(3);
24011                    }
24012    
24013                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
24014    
24015                    query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
24016    
24017                    query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
24018    
24019                    query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
24020    
24021                    if (orderByComparator != null) {
24022                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
24023    
24024                            if (orderByConditionFields.length > 0) {
24025                                    query.append(WHERE_AND);
24026                            }
24027    
24028                            for (int i = 0; i < orderByConditionFields.length; i++) {
24029                                    query.append(_ORDER_BY_ENTITY_ALIAS);
24030                                    query.append(orderByConditionFields[i]);
24031    
24032                                    if ((i + 1) < orderByConditionFields.length) {
24033                                            if (orderByComparator.isAscending() ^ previous) {
24034                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
24035                                            }
24036                                            else {
24037                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
24038                                            }
24039                                    }
24040                                    else {
24041                                            if (orderByComparator.isAscending() ^ previous) {
24042                                                    query.append(WHERE_GREATER_THAN);
24043                                            }
24044                                            else {
24045                                                    query.append(WHERE_LESSER_THAN);
24046                                            }
24047                                    }
24048                            }
24049    
24050                            query.append(ORDER_BY_CLAUSE);
24051    
24052                            String[] orderByFields = orderByComparator.getOrderByFields();
24053    
24054                            for (int i = 0; i < orderByFields.length; i++) {
24055                                    query.append(_ORDER_BY_ENTITY_ALIAS);
24056                                    query.append(orderByFields[i]);
24057    
24058                                    if ((i + 1) < orderByFields.length) {
24059                                            if (orderByComparator.isAscending() ^ previous) {
24060                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
24061                                            }
24062                                            else {
24063                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
24064                                            }
24065                                    }
24066                                    else {
24067                                            if (orderByComparator.isAscending() ^ previous) {
24068                                                    query.append(ORDER_BY_ASC);
24069                                            }
24070                                            else {
24071                                                    query.append(ORDER_BY_DESC);
24072                                            }
24073                                    }
24074                            }
24075                    }
24076                    else {
24077                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
24078                    }
24079    
24080                    String sql = query.toString();
24081    
24082                    Query q = session.createQuery(sql);
24083    
24084                    q.setFirstResult(0);
24085                    q.setMaxResults(2);
24086    
24087                    QueryPos qPos = QueryPos.getInstance(q);
24088    
24089                    qPos.add(companyId);
24090    
24091                    qPos.add(version);
24092    
24093                    qPos.add(status);
24094    
24095                    if (orderByComparator != null) {
24096                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
24097    
24098                            for (Object value : values) {
24099                                    qPos.add(value);
24100                            }
24101                    }
24102    
24103                    List<JournalArticle> list = q.list();
24104    
24105                    if (list.size() == 2) {
24106                            return list.get(1);
24107                    }
24108                    else {
24109                            return null;
24110                    }
24111            }
24112    
24113            /**
24114             * Removes all the journal articles where companyId = &#63; and version = &#63; and status = &#63; from the database.
24115             *
24116             * @param companyId the company ID
24117             * @param version the version
24118             * @param status the status
24119             * @throws SystemException if a system exception occurred
24120             */
24121            public void removeByC_V_ST(long companyId, double version, int status)
24122                    throws SystemException {
24123                    for (JournalArticle journalArticle : findByC_V_ST(companyId, version,
24124                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
24125                            remove(journalArticle);
24126                    }
24127            }
24128    
24129            /**
24130             * Returns the number of journal articles where companyId = &#63; and version = &#63; and status = &#63;.
24131             *
24132             * @param companyId the company ID
24133             * @param version the version
24134             * @param status the status
24135             * @return the number of matching journal articles
24136             * @throws SystemException if a system exception occurred
24137             */
24138            public int countByC_V_ST(long companyId, double version, int status)
24139                    throws SystemException {
24140                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_V_ST;
24141    
24142                    Object[] finderArgs = new Object[] { companyId, version, status };
24143    
24144                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
24145                                    this);
24146    
24147                    if (count == null) {
24148                            StringBundler query = new StringBundler(4);
24149    
24150                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
24151    
24152                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
24153    
24154                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
24155    
24156                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
24157    
24158                            String sql = query.toString();
24159    
24160                            Session session = null;
24161    
24162                            try {
24163                                    session = openSession();
24164    
24165                                    Query q = session.createQuery(sql);
24166    
24167                                    QueryPos qPos = QueryPos.getInstance(q);
24168    
24169                                    qPos.add(companyId);
24170    
24171                                    qPos.add(version);
24172    
24173                                    qPos.add(status);
24174    
24175                                    count = (Long)q.uniqueResult();
24176    
24177                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
24178                            }
24179                            catch (Exception e) {
24180                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
24181    
24182                                    throw processException(e);
24183                            }
24184                            finally {
24185                                    closeSession(session);
24186                            }
24187                    }
24188    
24189                    return count.intValue();
24190            }
24191    
24192            private static final String _FINDER_COLUMN_C_V_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
24193            private static final String _FINDER_COLUMN_C_V_ST_VERSION_2 = "journalArticle.version = ? AND ";
24194            private static final String _FINDER_COLUMN_C_V_ST_STATUS_2 = "journalArticle.status = ?";
24195    
24196            /**
24197             * Caches the journal article in the entity cache if it is enabled.
24198             *
24199             * @param journalArticle the journal article
24200             */
24201            public void cacheResult(JournalArticle journalArticle) {
24202                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24203                            JournalArticleImpl.class, journalArticle.getPrimaryKey(),
24204                            journalArticle);
24205    
24206                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
24207                            new Object[] {
24208                                    journalArticle.getUuid(),
24209                                    Long.valueOf(journalArticle.getGroupId())
24210                            }, journalArticle);
24211    
24212                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
24213                            new Object[] {
24214                                    Long.valueOf(journalArticle.getGroupId()),
24215                                    Long.valueOf(journalArticle.getClassNameId()),
24216                                    
24217                            journalArticle.getStructureId()
24218                            }, journalArticle);
24219    
24220                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
24221                            new Object[] {
24222                                    Long.valueOf(journalArticle.getGroupId()),
24223                                    
24224                            journalArticle.getArticleId(),
24225                                    Double.valueOf(journalArticle.getVersion())
24226                            }, journalArticle);
24227    
24228                    journalArticle.resetOriginalValues();
24229            }
24230    
24231            /**
24232             * Caches the journal articles in the entity cache if it is enabled.
24233             *
24234             * @param journalArticles the journal articles
24235             */
24236            public void cacheResult(List<JournalArticle> journalArticles) {
24237                    for (JournalArticle journalArticle : journalArticles) {
24238                            if (EntityCacheUtil.getResult(
24239                                                    JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24240                                                    JournalArticleImpl.class, journalArticle.getPrimaryKey()) == null) {
24241                                    cacheResult(journalArticle);
24242                            }
24243                            else {
24244                                    journalArticle.resetOriginalValues();
24245                            }
24246                    }
24247            }
24248    
24249            /**
24250             * Clears the cache for all journal articles.
24251             *
24252             * <p>
24253             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
24254             * </p>
24255             */
24256            @Override
24257            public void clearCache() {
24258                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
24259                            CacheRegistryUtil.clear(JournalArticleImpl.class.getName());
24260                    }
24261    
24262                    EntityCacheUtil.clearCache(JournalArticleImpl.class.getName());
24263    
24264                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
24265                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
24266                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
24267            }
24268    
24269            /**
24270             * Clears the cache for the journal article.
24271             *
24272             * <p>
24273             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
24274             * </p>
24275             */
24276            @Override
24277            public void clearCache(JournalArticle journalArticle) {
24278                    EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24279                            JournalArticleImpl.class, journalArticle.getPrimaryKey());
24280    
24281                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
24282                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
24283    
24284                    clearUniqueFindersCache(journalArticle);
24285            }
24286    
24287            @Override
24288            public void clearCache(List<JournalArticle> journalArticles) {
24289                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
24290                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
24291    
24292                    for (JournalArticle journalArticle : journalArticles) {
24293                            EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24294                                    JournalArticleImpl.class, journalArticle.getPrimaryKey());
24295    
24296                            clearUniqueFindersCache(journalArticle);
24297                    }
24298            }
24299    
24300            protected void cacheUniqueFindersCache(JournalArticle journalArticle) {
24301                    if (journalArticle.isNew()) {
24302                            Object[] args = new Object[] {
24303                                            journalArticle.getUuid(),
24304                                            Long.valueOf(journalArticle.getGroupId())
24305                                    };
24306    
24307                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
24308                                    Long.valueOf(1));
24309                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
24310                                    journalArticle);
24311    
24312                            args = new Object[] {
24313                                            Long.valueOf(journalArticle.getGroupId()),
24314                                            Long.valueOf(journalArticle.getClassNameId()),
24315                                            
24316                                            journalArticle.getStructureId()
24317                                    };
24318    
24319                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S, args,
24320                                    Long.valueOf(1));
24321                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S, args,
24322                                    journalArticle);
24323    
24324                            args = new Object[] {
24325                                            Long.valueOf(journalArticle.getGroupId()),
24326                                            
24327                                            journalArticle.getArticleId(),
24328                                            Double.valueOf(journalArticle.getVersion())
24329                                    };
24330    
24331                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V, args,
24332                                    Long.valueOf(1));
24333                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V, args,
24334                                    journalArticle);
24335                    }
24336                    else {
24337                            JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
24338    
24339                            if ((journalArticleModelImpl.getColumnBitmask() &
24340                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
24341                                    Object[] args = new Object[] {
24342                                                    journalArticle.getUuid(),
24343                                                    Long.valueOf(journalArticle.getGroupId())
24344                                            };
24345    
24346                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
24347                                            Long.valueOf(1));
24348                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
24349                                            journalArticle);
24350                            }
24351    
24352                            if ((journalArticleModelImpl.getColumnBitmask() &
24353                                            FINDER_PATH_FETCH_BY_G_C_S.getColumnBitmask()) != 0) {
24354                                    Object[] args = new Object[] {
24355                                                    Long.valueOf(journalArticle.getGroupId()),
24356                                                    Long.valueOf(journalArticle.getClassNameId()),
24357                                                    
24358                                                    journalArticle.getStructureId()
24359                                            };
24360    
24361                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S, args,
24362                                            Long.valueOf(1));
24363                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S, args,
24364                                            journalArticle);
24365                            }
24366    
24367                            if ((journalArticleModelImpl.getColumnBitmask() &
24368                                            FINDER_PATH_FETCH_BY_G_A_V.getColumnBitmask()) != 0) {
24369                                    Object[] args = new Object[] {
24370                                                    Long.valueOf(journalArticle.getGroupId()),
24371                                                    
24372                                                    journalArticle.getArticleId(),
24373                                                    Double.valueOf(journalArticle.getVersion())
24374                                            };
24375    
24376                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V, args,
24377                                            Long.valueOf(1));
24378                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V, args,
24379                                            journalArticle);
24380                            }
24381                    }
24382            }
24383    
24384            protected void clearUniqueFindersCache(JournalArticle journalArticle) {
24385                    JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
24386    
24387                    Object[] args = new Object[] {
24388                                    journalArticle.getUuid(),
24389                                    Long.valueOf(journalArticle.getGroupId())
24390                            };
24391    
24392                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
24393                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
24394    
24395                    if ((journalArticleModelImpl.getColumnBitmask() &
24396                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
24397                            args = new Object[] {
24398                                            journalArticleModelImpl.getOriginalUuid(),
24399                                            Long.valueOf(journalArticleModelImpl.getOriginalGroupId())
24400                                    };
24401    
24402                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
24403                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
24404                    }
24405    
24406                    args = new Object[] {
24407                                    Long.valueOf(journalArticle.getGroupId()),
24408                                    Long.valueOf(journalArticle.getClassNameId()),
24409                                    
24410                                    journalArticle.getStructureId()
24411                            };
24412    
24413                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
24414                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S, args);
24415    
24416                    if ((journalArticleModelImpl.getColumnBitmask() &
24417                                    FINDER_PATH_FETCH_BY_G_C_S.getColumnBitmask()) != 0) {
24418                            args = new Object[] {
24419                                            Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
24420                                            Long.valueOf(journalArticleModelImpl.getOriginalClassNameId()),
24421                                            
24422                                            journalArticleModelImpl.getOriginalStructureId()
24423                                    };
24424    
24425                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
24426                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S, args);
24427                    }
24428    
24429                    args = new Object[] {
24430                                    Long.valueOf(journalArticle.getGroupId()),
24431                                    
24432                                    journalArticle.getArticleId(),
24433                                    Double.valueOf(journalArticle.getVersion())
24434                            };
24435    
24436                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_V, args);
24437                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V, args);
24438    
24439                    if ((journalArticleModelImpl.getColumnBitmask() &
24440                                    FINDER_PATH_FETCH_BY_G_A_V.getColumnBitmask()) != 0) {
24441                            args = new Object[] {
24442                                            Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
24443                                            
24444                                            journalArticleModelImpl.getOriginalArticleId(),
24445                                            Double.valueOf(journalArticleModelImpl.getOriginalVersion())
24446                                    };
24447    
24448                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_V, args);
24449                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V, args);
24450                    }
24451            }
24452    
24453            /**
24454             * Creates a new journal article with the primary key. Does not add the journal article to the database.
24455             *
24456             * @param id the primary key for the new journal article
24457             * @return the new journal article
24458             */
24459            public JournalArticle create(long id) {
24460                    JournalArticle journalArticle = new JournalArticleImpl();
24461    
24462                    journalArticle.setNew(true);
24463                    journalArticle.setPrimaryKey(id);
24464    
24465                    String uuid = PortalUUIDUtil.generate();
24466    
24467                    journalArticle.setUuid(uuid);
24468    
24469                    return journalArticle;
24470            }
24471    
24472            /**
24473             * Removes the journal article with the primary key from the database. Also notifies the appropriate model listeners.
24474             *
24475             * @param id the primary key of the journal article
24476             * @return the journal article that was removed
24477             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
24478             * @throws SystemException if a system exception occurred
24479             */
24480            public JournalArticle remove(long id)
24481                    throws NoSuchArticleException, SystemException {
24482                    return remove(Long.valueOf(id));
24483            }
24484    
24485            /**
24486             * Removes the journal article with the primary key from the database. Also notifies the appropriate model listeners.
24487             *
24488             * @param primaryKey the primary key of the journal article
24489             * @return the journal article that was removed
24490             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
24491             * @throws SystemException if a system exception occurred
24492             */
24493            @Override
24494            public JournalArticle remove(Serializable primaryKey)
24495                    throws NoSuchArticleException, SystemException {
24496                    Session session = null;
24497    
24498                    try {
24499                            session = openSession();
24500    
24501                            JournalArticle journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
24502                                            primaryKey);
24503    
24504                            if (journalArticle == null) {
24505                                    if (_log.isWarnEnabled()) {
24506                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
24507                                    }
24508    
24509                                    throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
24510                                            primaryKey);
24511                            }
24512    
24513                            return remove(journalArticle);
24514                    }
24515                    catch (NoSuchArticleException nsee) {
24516                            throw nsee;
24517                    }
24518                    catch (Exception e) {
24519                            throw processException(e);
24520                    }
24521                    finally {
24522                            closeSession(session);
24523                    }
24524            }
24525    
24526            @Override
24527            protected JournalArticle removeImpl(JournalArticle journalArticle)
24528                    throws SystemException {
24529                    journalArticle = toUnwrappedModel(journalArticle);
24530    
24531                    Session session = null;
24532    
24533                    try {
24534                            session = openSession();
24535    
24536                            if (!session.contains(journalArticle)) {
24537                                    journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
24538                                                    journalArticle.getPrimaryKeyObj());
24539                            }
24540    
24541                            if (journalArticle != null) {
24542                                    session.delete(journalArticle);
24543                            }
24544                    }
24545                    catch (Exception e) {
24546                            throw processException(e);
24547                    }
24548                    finally {
24549                            closeSession(session);
24550                    }
24551    
24552                    if (journalArticle != null) {
24553                            clearCache(journalArticle);
24554                    }
24555    
24556                    return journalArticle;
24557            }
24558    
24559            @Override
24560            public JournalArticle updateImpl(
24561                    com.liferay.portlet.journal.model.JournalArticle journalArticle)
24562                    throws SystemException {
24563                    journalArticle = toUnwrappedModel(journalArticle);
24564    
24565                    boolean isNew = journalArticle.isNew();
24566    
24567                    JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
24568    
24569                    if (Validator.isNull(journalArticle.getUuid())) {
24570                            String uuid = PortalUUIDUtil.generate();
24571    
24572                            journalArticle.setUuid(uuid);
24573                    }
24574    
24575                    Session session = null;
24576    
24577                    try {
24578                            session = openSession();
24579    
24580                            if (journalArticle.isNew()) {
24581                                    session.save(journalArticle);
24582    
24583                                    journalArticle.setNew(false);
24584                            }
24585                            else {
24586                                    session.merge(journalArticle);
24587                            }
24588                    }
24589                    catch (Exception e) {
24590                            throw processException(e);
24591                    }
24592                    finally {
24593                            closeSession(session);
24594                    }
24595    
24596                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
24597    
24598                    if (isNew || !JournalArticleModelImpl.COLUMN_BITMASK_ENABLED) {
24599                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
24600                    }
24601    
24602                    else {
24603                            if ((journalArticleModelImpl.getColumnBitmask() &
24604                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
24605                                    Object[] args = new Object[] {
24606                                                    journalArticleModelImpl.getOriginalUuid()
24607                                            };
24608    
24609                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
24610                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
24611                                            args);
24612    
24613                                    args = new Object[] { journalArticleModelImpl.getUuid() };
24614    
24615                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
24616                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
24617                                            args);
24618                            }
24619    
24620                            if ((journalArticleModelImpl.getColumnBitmask() &
24621                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
24622                                    Object[] args = new Object[] {
24623                                                    journalArticleModelImpl.getOriginalUuid(),
24624                                                    Long.valueOf(journalArticleModelImpl.getOriginalCompanyId())
24625                                            };
24626    
24627                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
24628                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
24629                                            args);
24630    
24631                                    args = new Object[] {
24632                                                    journalArticleModelImpl.getUuid(),
24633                                                    Long.valueOf(journalArticleModelImpl.getCompanyId())
24634                                            };
24635    
24636                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
24637                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
24638                                            args);
24639                            }
24640    
24641                            if ((journalArticleModelImpl.getColumnBitmask() &
24642                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY.getColumnBitmask()) != 0) {
24643                                    Object[] args = new Object[] {
24644                                                    Long.valueOf(journalArticleModelImpl.getOriginalResourcePrimKey())
24645                                            };
24646    
24647                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
24648                                            args);
24649                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
24650                                            args);
24651    
24652                                    args = new Object[] {
24653                                                    Long.valueOf(journalArticleModelImpl.getResourcePrimKey())
24654                                            };
24655    
24656                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
24657                                            args);
24658                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
24659                                            args);
24660                            }
24661    
24662                            if ((journalArticleModelImpl.getColumnBitmask() &
24663                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
24664                                    Object[] args = new Object[] {
24665                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId())
24666                                            };
24667    
24668                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
24669                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
24670                                            args);
24671    
24672                                    args = new Object[] {
24673                                                    Long.valueOf(journalArticleModelImpl.getGroupId())
24674                                            };
24675    
24676                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
24677                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
24678                                            args);
24679                            }
24680    
24681                            if ((journalArticleModelImpl.getColumnBitmask() &
24682                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
24683                                    Object[] args = new Object[] {
24684                                                    Long.valueOf(journalArticleModelImpl.getOriginalCompanyId())
24685                                            };
24686    
24687                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
24688                                            args);
24689                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
24690                                            args);
24691    
24692                                    args = new Object[] {
24693                                                    Long.valueOf(journalArticleModelImpl.getCompanyId())
24694                                            };
24695    
24696                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
24697                                            args);
24698                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
24699                                            args);
24700                            }
24701    
24702                            if ((journalArticleModelImpl.getColumnBitmask() &
24703                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID.getColumnBitmask()) != 0) {
24704                                    Object[] args = new Object[] {
24705                                                    journalArticleModelImpl.getOriginalStructureId()
24706                                            };
24707    
24708                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
24709                                            args);
24710                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
24711                                            args);
24712    
24713                                    args = new Object[] { journalArticleModelImpl.getStructureId() };
24714    
24715                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
24716                                            args);
24717                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
24718                                            args);
24719                            }
24720    
24721                            if ((journalArticleModelImpl.getColumnBitmask() &
24722                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID.getColumnBitmask()) != 0) {
24723                                    Object[] args = new Object[] {
24724                                                    journalArticleModelImpl.getOriginalTemplateId()
24725                                            };
24726    
24727                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
24728                                            args);
24729                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID,
24730                                            args);
24731    
24732                                    args = new Object[] { journalArticleModelImpl.getTemplateId() };
24733    
24734                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
24735                                            args);
24736                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID,
24737                                            args);
24738                            }
24739    
24740                            if ((journalArticleModelImpl.getColumnBitmask() &
24741                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID.getColumnBitmask()) != 0) {
24742                                    Object[] args = new Object[] {
24743                                                    journalArticleModelImpl.getOriginalLayoutUuid()
24744                                            };
24745    
24746                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTUUID,
24747                                            args);
24748                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID,
24749                                            args);
24750    
24751                                    args = new Object[] { journalArticleModelImpl.getLayoutUuid() };
24752    
24753                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTUUID,
24754                                            args);
24755                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID,
24756                                            args);
24757                            }
24758    
24759                            if ((journalArticleModelImpl.getColumnBitmask() &
24760                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID.getColumnBitmask()) != 0) {
24761                                    Object[] args = new Object[] {
24762                                                    Long.valueOf(journalArticleModelImpl.getOriginalSmallImageId())
24763                                            };
24764    
24765                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
24766                                            args);
24767                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID,
24768                                            args);
24769    
24770                                    args = new Object[] {
24771                                                    Long.valueOf(journalArticleModelImpl.getSmallImageId())
24772                                            };
24773    
24774                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
24775                                            args);
24776                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID,
24777                                            args);
24778                            }
24779    
24780                            if ((journalArticleModelImpl.getColumnBitmask() &
24781                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST.getColumnBitmask()) != 0) {
24782                                    Object[] args = new Object[] {
24783                                                    Long.valueOf(journalArticleModelImpl.getOriginalResourcePrimKey()),
24784                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
24785                                            };
24786    
24787                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_ST, args);
24788                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST,
24789                                            args);
24790    
24791                                    args = new Object[] {
24792                                                    Long.valueOf(journalArticleModelImpl.getResourcePrimKey()),
24793                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
24794                                            };
24795    
24796                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_ST, args);
24797                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST,
24798                                            args);
24799                            }
24800    
24801                            if ((journalArticleModelImpl.getColumnBitmask() &
24802                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U.getColumnBitmask()) != 0) {
24803                                    Object[] args = new Object[] {
24804                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
24805                                                    Long.valueOf(journalArticleModelImpl.getOriginalUserId())
24806                                            };
24807    
24808                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
24809                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
24810                                            args);
24811    
24812                                    args = new Object[] {
24813                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
24814                                                    Long.valueOf(journalArticleModelImpl.getUserId())
24815                                            };
24816    
24817                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
24818                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
24819                                            args);
24820                            }
24821    
24822                            if ((journalArticleModelImpl.getColumnBitmask() &
24823                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F.getColumnBitmask()) != 0) {
24824                                    Object[] args = new Object[] {
24825                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
24826                                                    Long.valueOf(journalArticleModelImpl.getOriginalFolderId())
24827                                            };
24828    
24829                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
24830                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
24831                                            args);
24832    
24833                                    args = new Object[] {
24834                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
24835                                                    Long.valueOf(journalArticleModelImpl.getFolderId())
24836                                            };
24837    
24838                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
24839                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
24840                                            args);
24841                            }
24842    
24843                            if ((journalArticleModelImpl.getColumnBitmask() &
24844                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A.getColumnBitmask()) != 0) {
24845                                    Object[] args = new Object[] {
24846                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
24847                                                    
24848                                                    journalArticleModelImpl.getOriginalArticleId()
24849                                            };
24850    
24851                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
24852                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
24853                                            args);
24854    
24855                                    args = new Object[] {
24856                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
24857                                                    
24858                                                    journalArticleModelImpl.getArticleId()
24859                                            };
24860    
24861                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
24862                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
24863                                            args);
24864                            }
24865    
24866                            if ((journalArticleModelImpl.getColumnBitmask() &
24867                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT.getColumnBitmask()) != 0) {
24868                                    Object[] args = new Object[] {
24869                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
24870                                                    
24871                                                    journalArticleModelImpl.getOriginalUrlTitle()
24872                                            };
24873    
24874                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
24875                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT,
24876                                            args);
24877    
24878                                    args = new Object[] {
24879                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
24880                                                    
24881                                                    journalArticleModelImpl.getUrlTitle()
24882                                            };
24883    
24884                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
24885                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT,
24886                                            args);
24887                            }
24888    
24889                            if ((journalArticleModelImpl.getColumnBitmask() &
24890                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
24891                                    Object[] args = new Object[] {
24892                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
24893                                                    
24894                                                    journalArticleModelImpl.getOriginalStructureId()
24895                                            };
24896    
24897                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
24898                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
24899                                            args);
24900    
24901                                    args = new Object[] {
24902                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
24903                                                    
24904                                                    journalArticleModelImpl.getStructureId()
24905                                            };
24906    
24907                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
24908                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
24909                                            args);
24910                            }
24911    
24912                            if ((journalArticleModelImpl.getColumnBitmask() &
24913                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T.getColumnBitmask()) != 0) {
24914                                    Object[] args = new Object[] {
24915                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
24916                                                    
24917                                                    journalArticleModelImpl.getOriginalTemplateId()
24918                                            };
24919    
24920                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_T, args);
24921                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T,
24922                                            args);
24923    
24924                                    args = new Object[] {
24925                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
24926                                                    
24927                                                    journalArticleModelImpl.getTemplateId()
24928                                            };
24929    
24930                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_T, args);
24931                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T,
24932                                            args);
24933                            }
24934    
24935                            if ((journalArticleModelImpl.getColumnBitmask() &
24936                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L.getColumnBitmask()) != 0) {
24937                                    Object[] args = new Object[] {
24938                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
24939                                                    
24940                                                    journalArticleModelImpl.getOriginalLayoutUuid()
24941                                            };
24942    
24943                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_L, args);
24944                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L,
24945                                            args);
24946    
24947                                    args = new Object[] {
24948                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
24949                                                    
24950                                                    journalArticleModelImpl.getLayoutUuid()
24951                                            };
24952    
24953                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_L, args);
24954                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L,
24955                                            args);
24956                            }
24957    
24958                            if ((journalArticleModelImpl.getColumnBitmask() &
24959                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST.getColumnBitmask()) != 0) {
24960                                    Object[] args = new Object[] {
24961                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
24962                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
24963                                            };
24964    
24965                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_ST, args);
24966                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST,
24967                                            args);
24968    
24969                                    args = new Object[] {
24970                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
24971                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
24972                                            };
24973    
24974                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_ST, args);
24975                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST,
24976                                            args);
24977                            }
24978    
24979                            if ((journalArticleModelImpl.getColumnBitmask() &
24980                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V.getColumnBitmask()) != 0) {
24981                                    Object[] args = new Object[] {
24982                                                    Long.valueOf(journalArticleModelImpl.getOriginalCompanyId()),
24983                                                    Double.valueOf(journalArticleModelImpl.getOriginalVersion())
24984                                            };
24985    
24986                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V, args);
24987                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V,
24988                                            args);
24989    
24990                                    args = new Object[] {
24991                                                    Long.valueOf(journalArticleModelImpl.getCompanyId()),
24992                                                    Double.valueOf(journalArticleModelImpl.getVersion())
24993                                            };
24994    
24995                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V, args);
24996                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V,
24997                                            args);
24998                            }
24999    
25000                            if ((journalArticleModelImpl.getColumnBitmask() &
25001                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST.getColumnBitmask()) != 0) {
25002                                    Object[] args = new Object[] {
25003                                                    Long.valueOf(journalArticleModelImpl.getOriginalCompanyId()),
25004                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
25005                                            };
25006    
25007                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_ST, args);
25008                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST,
25009                                            args);
25010    
25011                                    args = new Object[] {
25012                                                    Long.valueOf(journalArticleModelImpl.getCompanyId()),
25013                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
25014                                            };
25015    
25016                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_ST, args);
25017                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST,
25018                                            args);
25019                            }
25020    
25021                            if ((journalArticleModelImpl.getColumnBitmask() &
25022                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST.getColumnBitmask()) != 0) {
25023                                    Object[] args = new Object[] {
25024                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
25025                                                    Long.valueOf(journalArticleModelImpl.getOriginalFolderId()),
25026                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
25027                                            };
25028    
25029                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_ST, args);
25030                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST,
25031                                            args);
25032    
25033                                    args = new Object[] {
25034                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
25035                                                    Long.valueOf(journalArticleModelImpl.getFolderId()),
25036                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
25037                                            };
25038    
25039                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_ST, args);
25040                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST,
25041                                            args);
25042                            }
25043    
25044                            if ((journalArticleModelImpl.getColumnBitmask() &
25045                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C.getColumnBitmask()) != 0) {
25046                                    Object[] args = new Object[] {
25047                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
25048                                                    Long.valueOf(journalArticleModelImpl.getOriginalClassNameId()),
25049                                                    Long.valueOf(journalArticleModelImpl.getOriginalClassPK())
25050                                            };
25051    
25052                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
25053                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
25054                                            args);
25055    
25056                                    args = new Object[] {
25057                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
25058                                                    Long.valueOf(journalArticleModelImpl.getClassNameId()),
25059                                                    Long.valueOf(journalArticleModelImpl.getClassPK())
25060                                            };
25061    
25062                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
25063                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
25064                                            args);
25065                            }
25066    
25067                            if ((journalArticleModelImpl.getColumnBitmask() &
25068                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T.getColumnBitmask()) != 0) {
25069                                    Object[] args = new Object[] {
25070                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
25071                                                    Long.valueOf(journalArticleModelImpl.getOriginalClassNameId()),
25072                                                    
25073                                                    journalArticleModelImpl.getOriginalTemplateId()
25074                                            };
25075    
25076                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args);
25077                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T,
25078                                            args);
25079    
25080                                    args = new Object[] {
25081                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
25082                                                    Long.valueOf(journalArticleModelImpl.getClassNameId()),
25083                                                    
25084                                                    journalArticleModelImpl.getTemplateId()
25085                                            };
25086    
25087                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args);
25088                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T,
25089                                            args);
25090                            }
25091    
25092                            if ((journalArticleModelImpl.getColumnBitmask() &
25093                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L.getColumnBitmask()) != 0) {
25094                                    Object[] args = new Object[] {
25095                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
25096                                                    Long.valueOf(journalArticleModelImpl.getOriginalClassNameId()),
25097                                                    
25098                                                    journalArticleModelImpl.getOriginalLayoutUuid()
25099                                            };
25100    
25101                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
25102                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
25103                                            args);
25104    
25105                                    args = new Object[] {
25106                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
25107                                                    Long.valueOf(journalArticleModelImpl.getClassNameId()),
25108                                                    
25109                                                    journalArticleModelImpl.getLayoutUuid()
25110                                            };
25111    
25112                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
25113                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
25114                                            args);
25115                            }
25116    
25117                            if ((journalArticleModelImpl.getColumnBitmask() &
25118                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C.getColumnBitmask()) != 0) {
25119                                    Object[] args = new Object[] {
25120                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
25121                                                    Long.valueOf(journalArticleModelImpl.getOriginalUserId()),
25122                                                    Long.valueOf(journalArticleModelImpl.getOriginalClassNameId())
25123                                            };
25124    
25125                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_C, args);
25126                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C,
25127                                            args);
25128    
25129                                    args = new Object[] {
25130                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
25131                                                    Long.valueOf(journalArticleModelImpl.getUserId()),
25132                                                    Long.valueOf(journalArticleModelImpl.getClassNameId())
25133                                            };
25134    
25135                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_C, args);
25136                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C,
25137                                            args);
25138                            }
25139    
25140                            if ((journalArticleModelImpl.getColumnBitmask() &
25141                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST.getColumnBitmask()) != 0) {
25142                                    Object[] args = new Object[] {
25143                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
25144                                                    
25145                                                    journalArticleModelImpl.getOriginalArticleId(),
25146                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
25147                                            };
25148    
25149                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_ST, args);
25150                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST,
25151                                            args);
25152    
25153                                    args = new Object[] {
25154                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
25155                                                    
25156                                                    journalArticleModelImpl.getArticleId(),
25157                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
25158                                            };
25159    
25160                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_ST, args);
25161                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST,
25162                                            args);
25163                            }
25164    
25165                            if ((journalArticleModelImpl.getColumnBitmask() &
25166                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST.getColumnBitmask()) != 0) {
25167                                    Object[] args = new Object[] {
25168                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
25169                                                    
25170                                                    journalArticleModelImpl.getOriginalUrlTitle(),
25171                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
25172                                            };
25173    
25174                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT_ST, args);
25175                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST,
25176                                            args);
25177    
25178                                    args = new Object[] {
25179                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
25180                                                    
25181                                                    journalArticleModelImpl.getUrlTitle(),
25182                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
25183                                            };
25184    
25185                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT_ST, args);
25186                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST,
25187                                            args);
25188                            }
25189    
25190                            if ((journalArticleModelImpl.getColumnBitmask() &
25191                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST.getColumnBitmask()) != 0) {
25192                                    Object[] args = new Object[] {
25193                                                    Long.valueOf(journalArticleModelImpl.getOriginalCompanyId()),
25194                                                    Double.valueOf(journalArticleModelImpl.getOriginalVersion()),
25195                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
25196                                            };
25197    
25198                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V_ST, args);
25199                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST,
25200                                            args);
25201    
25202                                    args = new Object[] {
25203                                                    Long.valueOf(journalArticleModelImpl.getCompanyId()),
25204                                                    Double.valueOf(journalArticleModelImpl.getVersion()),
25205                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
25206                                            };
25207    
25208                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V_ST, args);
25209                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST,
25210                                            args);
25211                            }
25212                    }
25213    
25214                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
25215                            JournalArticleImpl.class, journalArticle.getPrimaryKey(),
25216                            journalArticle);
25217    
25218                    clearUniqueFindersCache(journalArticle);
25219                    cacheUniqueFindersCache(journalArticle);
25220    
25221                    return journalArticle;
25222            }
25223    
25224            protected JournalArticle toUnwrappedModel(JournalArticle journalArticle) {
25225                    if (journalArticle instanceof JournalArticleImpl) {
25226                            return journalArticle;
25227                    }
25228    
25229                    JournalArticleImpl journalArticleImpl = new JournalArticleImpl();
25230    
25231                    journalArticleImpl.setNew(journalArticle.isNew());
25232                    journalArticleImpl.setPrimaryKey(journalArticle.getPrimaryKey());
25233    
25234                    journalArticleImpl.setUuid(journalArticle.getUuid());
25235                    journalArticleImpl.setId(journalArticle.getId());
25236                    journalArticleImpl.setResourcePrimKey(journalArticle.getResourcePrimKey());
25237                    journalArticleImpl.setGroupId(journalArticle.getGroupId());
25238                    journalArticleImpl.setCompanyId(journalArticle.getCompanyId());
25239                    journalArticleImpl.setUserId(journalArticle.getUserId());
25240                    journalArticleImpl.setUserName(journalArticle.getUserName());
25241                    journalArticleImpl.setCreateDate(journalArticle.getCreateDate());
25242                    journalArticleImpl.setModifiedDate(journalArticle.getModifiedDate());
25243                    journalArticleImpl.setFolderId(journalArticle.getFolderId());
25244                    journalArticleImpl.setClassNameId(journalArticle.getClassNameId());
25245                    journalArticleImpl.setClassPK(journalArticle.getClassPK());
25246                    journalArticleImpl.setArticleId(journalArticle.getArticleId());
25247                    journalArticleImpl.setVersion(journalArticle.getVersion());
25248                    journalArticleImpl.setTitle(journalArticle.getTitle());
25249                    journalArticleImpl.setUrlTitle(journalArticle.getUrlTitle());
25250                    journalArticleImpl.setDescription(journalArticle.getDescription());
25251                    journalArticleImpl.setContent(journalArticle.getContent());
25252                    journalArticleImpl.setType(journalArticle.getType());
25253                    journalArticleImpl.setStructureId(journalArticle.getStructureId());
25254                    journalArticleImpl.setTemplateId(journalArticle.getTemplateId());
25255                    journalArticleImpl.setLayoutUuid(journalArticle.getLayoutUuid());
25256                    journalArticleImpl.setDisplayDate(journalArticle.getDisplayDate());
25257                    journalArticleImpl.setExpirationDate(journalArticle.getExpirationDate());
25258                    journalArticleImpl.setReviewDate(journalArticle.getReviewDate());
25259                    journalArticleImpl.setIndexable(journalArticle.isIndexable());
25260                    journalArticleImpl.setSmallImage(journalArticle.isSmallImage());
25261                    journalArticleImpl.setSmallImageId(journalArticle.getSmallImageId());
25262                    journalArticleImpl.setSmallImageURL(journalArticle.getSmallImageURL());
25263                    journalArticleImpl.setStatus(journalArticle.getStatus());
25264                    journalArticleImpl.setStatusByUserId(journalArticle.getStatusByUserId());
25265                    journalArticleImpl.setStatusByUserName(journalArticle.getStatusByUserName());
25266                    journalArticleImpl.setStatusDate(journalArticle.getStatusDate());
25267    
25268                    return journalArticleImpl;
25269            }
25270    
25271            /**
25272             * Returns the journal article with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
25273             *
25274             * @param primaryKey the primary key of the journal article
25275             * @return the journal article
25276             * @throws com.liferay.portal.NoSuchModelException if a journal article with the primary key could not be found
25277             * @throws SystemException if a system exception occurred
25278             */
25279            @Override
25280            public JournalArticle findByPrimaryKey(Serializable primaryKey)
25281                    throws NoSuchModelException, SystemException {
25282                    return findByPrimaryKey(((Long)primaryKey).longValue());
25283            }
25284    
25285            /**
25286             * Returns the journal article with the primary key or throws a {@link com.liferay.portlet.journal.NoSuchArticleException} if it could not be found.
25287             *
25288             * @param id the primary key of the journal article
25289             * @return the journal article
25290             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
25291             * @throws SystemException if a system exception occurred
25292             */
25293            public JournalArticle findByPrimaryKey(long id)
25294                    throws NoSuchArticleException, SystemException {
25295                    JournalArticle journalArticle = fetchByPrimaryKey(id);
25296    
25297                    if (journalArticle == null) {
25298                            if (_log.isWarnEnabled()) {
25299                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + id);
25300                            }
25301    
25302                            throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
25303                                    id);
25304                    }
25305    
25306                    return journalArticle;
25307            }
25308    
25309            /**
25310             * Returns the journal article with the primary key or returns <code>null</code> if it could not be found.
25311             *
25312             * @param primaryKey the primary key of the journal article
25313             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
25314             * @throws SystemException if a system exception occurred
25315             */
25316            @Override
25317            public JournalArticle fetchByPrimaryKey(Serializable primaryKey)
25318                    throws SystemException {
25319                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
25320            }
25321    
25322            /**
25323             * Returns the journal article with the primary key or returns <code>null</code> if it could not be found.
25324             *
25325             * @param id the primary key of the journal article
25326             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
25327             * @throws SystemException if a system exception occurred
25328             */
25329            public JournalArticle fetchByPrimaryKey(long id) throws SystemException {
25330                    JournalArticle journalArticle = (JournalArticle)EntityCacheUtil.getResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
25331                                    JournalArticleImpl.class, id);
25332    
25333                    if (journalArticle == _nullJournalArticle) {
25334                            return null;
25335                    }
25336    
25337                    if (journalArticle == null) {
25338                            Session session = null;
25339    
25340                            try {
25341                                    session = openSession();
25342    
25343                                    journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
25344                                                    Long.valueOf(id));
25345    
25346                                    if (journalArticle != null) {
25347                                            cacheResult(journalArticle);
25348                                    }
25349                                    else {
25350                                            EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
25351                                                    JournalArticleImpl.class, id, _nullJournalArticle);
25352                                    }
25353                            }
25354                            catch (Exception e) {
25355                                    EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
25356                                            JournalArticleImpl.class, id);
25357    
25358                                    throw processException(e);
25359                            }
25360                            finally {
25361                                    closeSession(session);
25362                            }
25363                    }
25364    
25365                    return journalArticle;
25366            }
25367    
25368            /**
25369             * Returns all the journal articles.
25370             *
25371             * @return the journal articles
25372             * @throws SystemException if a system exception occurred
25373             */
25374            public List<JournalArticle> findAll() throws SystemException {
25375                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
25376            }
25377    
25378            /**
25379             * Returns a range of all the journal articles.
25380             *
25381             * <p>
25382             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
25383             * </p>
25384             *
25385             * @param start the lower bound of the range of journal articles
25386             * @param end the upper bound of the range of journal articles (not inclusive)
25387             * @return the range of journal articles
25388             * @throws SystemException if a system exception occurred
25389             */
25390            public List<JournalArticle> findAll(int start, int end)
25391                    throws SystemException {
25392                    return findAll(start, end, null);
25393            }
25394    
25395            /**
25396             * Returns an ordered range of all the journal articles.
25397             *
25398             * <p>
25399             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
25400             * </p>
25401             *
25402             * @param start the lower bound of the range of journal articles
25403             * @param end the upper bound of the range of journal articles (not inclusive)
25404             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
25405             * @return the ordered range of journal articles
25406             * @throws SystemException if a system exception occurred
25407             */
25408            public List<JournalArticle> findAll(int start, int end,
25409                    OrderByComparator orderByComparator) throws SystemException {
25410                    boolean pagination = true;
25411                    FinderPath finderPath = null;
25412                    Object[] finderArgs = null;
25413    
25414                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
25415                                    (orderByComparator == null)) {
25416                            pagination = false;
25417                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
25418                            finderArgs = FINDER_ARGS_EMPTY;
25419                    }
25420                    else {
25421                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
25422                            finderArgs = new Object[] { start, end, orderByComparator };
25423                    }
25424    
25425                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
25426                                    finderArgs, this);
25427    
25428                    if (list == null) {
25429                            StringBundler query = null;
25430                            String sql = null;
25431    
25432                            if (orderByComparator != null) {
25433                                    query = new StringBundler(2 +
25434                                                    (orderByComparator.getOrderByFields().length * 3));
25435    
25436                                    query.append(_SQL_SELECT_JOURNALARTICLE);
25437    
25438                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
25439                                            orderByComparator);
25440    
25441                                    sql = query.toString();
25442                            }
25443                            else {
25444                                    sql = _SQL_SELECT_JOURNALARTICLE;
25445    
25446                                    if (pagination) {
25447                                            sql = sql.concat(JournalArticleModelImpl.ORDER_BY_JPQL);
25448                                    }
25449                            }
25450    
25451                            Session session = null;
25452    
25453                            try {
25454                                    session = openSession();
25455    
25456                                    Query q = session.createQuery(sql);
25457    
25458                                    if (!pagination) {
25459                                            list = (List<JournalArticle>)QueryUtil.list(q,
25460                                                            getDialect(), start, end, false);
25461    
25462                                            Collections.sort(list);
25463    
25464                                            list = new UnmodifiableList<JournalArticle>(list);
25465                                    }
25466                                    else {
25467                                            list = (List<JournalArticle>)QueryUtil.list(q,
25468                                                            getDialect(), start, end);
25469                                    }
25470    
25471                                    cacheResult(list);
25472    
25473                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
25474                            }
25475                            catch (Exception e) {
25476                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
25477    
25478                                    throw processException(e);
25479                            }
25480                            finally {
25481                                    closeSession(session);
25482                            }
25483                    }
25484    
25485                    return list;
25486            }
25487    
25488            /**
25489             * Removes all the journal articles from the database.
25490             *
25491             * @throws SystemException if a system exception occurred
25492             */
25493            public void removeAll() throws SystemException {
25494                    for (JournalArticle journalArticle : findAll()) {
25495                            remove(journalArticle);
25496                    }
25497            }
25498    
25499            /**
25500             * Returns the number of journal articles.
25501             *
25502             * @return the number of journal articles
25503             * @throws SystemException if a system exception occurred
25504             */
25505            public int countAll() throws SystemException {
25506                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
25507                                    FINDER_ARGS_EMPTY, this);
25508    
25509                    if (count == null) {
25510                            Session session = null;
25511    
25512                            try {
25513                                    session = openSession();
25514    
25515                                    Query q = session.createQuery(_SQL_COUNT_JOURNALARTICLE);
25516    
25517                                    count = (Long)q.uniqueResult();
25518    
25519                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
25520                                            FINDER_ARGS_EMPTY, count);
25521                            }
25522                            catch (Exception e) {
25523                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
25524                                            FINDER_ARGS_EMPTY);
25525    
25526                                    throw processException(e);
25527                            }
25528                            finally {
25529                                    closeSession(session);
25530                            }
25531                    }
25532    
25533                    return count.intValue();
25534            }
25535    
25536            /**
25537             * Initializes the journal article persistence.
25538             */
25539            public void afterPropertiesSet() {
25540                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
25541                                            com.liferay.portal.util.PropsUtil.get(
25542                                                    "value.object.listener.com.liferay.portlet.journal.model.JournalArticle")));
25543    
25544                    if (listenerClassNames.length > 0) {
25545                            try {
25546                                    List<ModelListener<JournalArticle>> listenersList = new ArrayList<ModelListener<JournalArticle>>();
25547    
25548                                    for (String listenerClassName : listenerClassNames) {
25549                                            listenersList.add((ModelListener<JournalArticle>)InstanceFactory.newInstance(
25550                                                            listenerClassName));
25551                                    }
25552    
25553                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
25554                            }
25555                            catch (Exception e) {
25556                                    _log.error(e);
25557                            }
25558                    }
25559            }
25560    
25561            public void destroy() {
25562                    EntityCacheUtil.removeCache(JournalArticleImpl.class.getName());
25563                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
25564                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
25565                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
25566            }
25567    
25568            private static final String _SQL_SELECT_JOURNALARTICLE = "SELECT journalArticle FROM JournalArticle journalArticle";
25569            private static final String _SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT journalArticle FROM JournalArticle journalArticle WHERE ";
25570            private static final String _SQL_COUNT_JOURNALARTICLE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle";
25571            private static final String _SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle WHERE ";
25572    
25573            private static String _removeConjunction(String sql) {
25574                    int pos = sql.indexOf(" AND ");
25575    
25576                    if (pos != -1) {
25577                            sql = sql.substring(0, pos);
25578                    }
25579    
25580                    return sql;
25581            }
25582    
25583            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "journalArticle.resourcePrimKey";
25584            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT DISTINCT {journalArticle.*} FROM JournalArticle journalArticle WHERE ";
25585            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1 =
25586                    "SELECT {JournalArticle.*} FROM (SELECT DISTINCT journalArticle.id_ FROM JournalArticle journalArticle WHERE ";
25587            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2 =
25588                    ") TEMP_TABLE INNER JOIN JournalArticle ON TEMP_TABLE.id_ = JournalArticle.id_";
25589            private static final String _FILTER_SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(DISTINCT journalArticle.id_) AS COUNT_VALUE FROM JournalArticle journalArticle WHERE ";
25590            private static final String _FILTER_ENTITY_ALIAS = "journalArticle";
25591            private static final String _FILTER_ENTITY_TABLE = "JournalArticle";
25592            private static final String _ORDER_BY_ENTITY_ALIAS = "journalArticle.";
25593            private static final String _ORDER_BY_ENTITY_TABLE = "JournalArticle.";
25594            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalArticle exists with the primary key ";
25595            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalArticle exists with the key {";
25596            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
25597            private static Log _log = LogFactoryUtil.getLog(JournalArticlePersistenceImpl.class);
25598            private static JournalArticle _nullJournalArticle = new JournalArticleImpl() {
25599                            @Override
25600                            public Object clone() {
25601                                    return this;
25602                            }
25603    
25604                            @Override
25605                            public CacheModel<JournalArticle> toCacheModel() {
25606                                    return _nullJournalArticleCacheModel;
25607                            }
25608                    };
25609    
25610            private static CacheModel<JournalArticle> _nullJournalArticleCacheModel = new CacheModel<JournalArticle>() {
25611                            public JournalArticle toEntityModel() {
25612                                    return _nullJournalArticle;
25613                            }
25614                    };
25615    }