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.kernel.cache.CacheRegistryUtil;
018    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
019    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
020    import com.liferay.portal.kernel.dao.orm.FinderPath;
021    import com.liferay.portal.kernel.dao.orm.Query;
022    import com.liferay.portal.kernel.dao.orm.QueryPos;
023    import com.liferay.portal.kernel.dao.orm.QueryUtil;
024    import com.liferay.portal.kernel.dao.orm.SQLQuery;
025    import com.liferay.portal.kernel.dao.orm.Session;
026    import com.liferay.portal.kernel.exception.SystemException;
027    import com.liferay.portal.kernel.log.Log;
028    import com.liferay.portal.kernel.log.LogFactoryUtil;
029    import com.liferay.portal.kernel.util.ArrayUtil;
030    import com.liferay.portal.kernel.util.GetterUtil;
031    import com.liferay.portal.kernel.util.InstanceFactory;
032    import com.liferay.portal.kernel.util.OrderByComparator;
033    import com.liferay.portal.kernel.util.StringBundler;
034    import com.liferay.portal.kernel.util.StringPool;
035    import com.liferay.portal.kernel.util.StringUtil;
036    import com.liferay.portal.kernel.util.UnmodifiableList;
037    import com.liferay.portal.kernel.util.Validator;
038    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
039    import com.liferay.portal.model.CacheModel;
040    import com.liferay.portal.model.ModelListener;
041    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
042    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
043    
044    import com.liferay.portlet.journal.NoSuchArticleException;
045    import com.liferay.portlet.journal.model.JournalArticle;
046    import com.liferay.portlet.journal.model.impl.JournalArticleImpl;
047    import com.liferay.portlet.journal.model.impl.JournalArticleModelImpl;
048    
049    import java.io.Serializable;
050    
051    import java.util.ArrayList;
052    import java.util.Collections;
053    import java.util.List;
054    
055    /**
056     * The persistence implementation for the journal article service.
057     *
058     * <p>
059     * Caching information and settings can be found in <code>portal.properties</code>
060     * </p>
061     *
062     * @author Brian Wing Shun Chan
063     * @see JournalArticlePersistence
064     * @see JournalArticleUtil
065     * @generated
066     */
067    public class JournalArticlePersistenceImpl extends BasePersistenceImpl<JournalArticle>
068            implements JournalArticlePersistence {
069            /*
070             * NOTE FOR DEVELOPERS:
071             *
072             * 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.
073             */
074            public static final String FINDER_CLASS_NAME_ENTITY = JournalArticleImpl.class.getName();
075            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
076                    ".List1";
077            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
078                    ".List2";
079            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
080                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
081                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
082                            "findAll", new String[0]);
083            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
084                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
085                            JournalArticleImpl.class,
086                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
087            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
088                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
089                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
090            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
091                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
092                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
093                            "findByUuid",
094                            new String[] {
095                                    String.class.getName(),
096                                    
097                            Integer.class.getName(), Integer.class.getName(),
098                                    OrderByComparator.class.getName()
099                            });
100            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
101                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
102                            JournalArticleImpl.class,
103                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
104                            new String[] { String.class.getName() },
105                            JournalArticleModelImpl.UUID_COLUMN_BITMASK |
106                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
107                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
108            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
109                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
110                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
111                            new String[] { String.class.getName() });
112    
113            /**
114             * Returns all the journal articles where uuid = &#63;.
115             *
116             * @param uuid the uuid
117             * @return the matching journal articles
118             * @throws SystemException if a system exception occurred
119             */
120            public List<JournalArticle> findByUuid(String uuid)
121                    throws SystemException {
122                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
123            }
124    
125            /**
126             * Returns a range of all the journal articles where uuid = &#63;.
127             *
128             * <p>
129             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
130             * </p>
131             *
132             * @param uuid the uuid
133             * @param start the lower bound of the range of journal articles
134             * @param end the upper bound of the range of journal articles (not inclusive)
135             * @return the range of matching journal articles
136             * @throws SystemException if a system exception occurred
137             */
138            public List<JournalArticle> findByUuid(String uuid, int start, int end)
139                    throws SystemException {
140                    return findByUuid(uuid, start, end, null);
141            }
142    
143            /**
144             * Returns an ordered range of all the journal articles where uuid = &#63;.
145             *
146             * <p>
147             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
148             * </p>
149             *
150             * @param uuid the uuid
151             * @param start the lower bound of the range of journal articles
152             * @param end the upper bound of the range of journal articles (not inclusive)
153             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
154             * @return the ordered range of matching journal articles
155             * @throws SystemException if a system exception occurred
156             */
157            public List<JournalArticle> findByUuid(String uuid, int start, int end,
158                    OrderByComparator orderByComparator) throws SystemException {
159                    boolean pagination = true;
160                    FinderPath finderPath = null;
161                    Object[] finderArgs = null;
162    
163                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
164                                    (orderByComparator == null)) {
165                            pagination = false;
166                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
167                            finderArgs = new Object[] { uuid };
168                    }
169                    else {
170                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
171                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
172                    }
173    
174                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
175                                    finderArgs, this);
176    
177                    if ((list != null) && !list.isEmpty()) {
178                            for (JournalArticle journalArticle : list) {
179                                    if (!Validator.equals(uuid, journalArticle.getUuid())) {
180                                            list = null;
181    
182                                            break;
183                                    }
184                            }
185                    }
186    
187                    if (list == null) {
188                            StringBundler query = null;
189    
190                            if (orderByComparator != null) {
191                                    query = new StringBundler(3 +
192                                                    (orderByComparator.getOrderByFields().length * 3));
193                            }
194                            else {
195                                    query = new StringBundler(3);
196                            }
197    
198                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
199    
200                            boolean bindUuid = false;
201    
202                            if (uuid == null) {
203                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
204                            }
205                            else if (uuid.equals(StringPool.BLANK)) {
206                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
207                            }
208                            else {
209                                    bindUuid = true;
210    
211                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
212                            }
213    
214                            if (orderByComparator != null) {
215                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
216                                            orderByComparator);
217                            }
218                            else
219                             if (pagination) {
220                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
221                            }
222    
223                            String sql = query.toString();
224    
225                            Session session = null;
226    
227                            try {
228                                    session = openSession();
229    
230                                    Query q = session.createQuery(sql);
231    
232                                    QueryPos qPos = QueryPos.getInstance(q);
233    
234                                    if (bindUuid) {
235                                            qPos.add(uuid);
236                                    }
237    
238                                    if (!pagination) {
239                                            list = (List<JournalArticle>)QueryUtil.list(q,
240                                                            getDialect(), start, end, false);
241    
242                                            Collections.sort(list);
243    
244                                            list = new UnmodifiableList<JournalArticle>(list);
245                                    }
246                                    else {
247                                            list = (List<JournalArticle>)QueryUtil.list(q,
248                                                            getDialect(), start, end);
249                                    }
250    
251                                    cacheResult(list);
252    
253                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
254                            }
255                            catch (Exception e) {
256                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
257    
258                                    throw processException(e);
259                            }
260                            finally {
261                                    closeSession(session);
262                            }
263                    }
264    
265                    return list;
266            }
267    
268            /**
269             * Returns the first journal article in the ordered set where uuid = &#63;.
270             *
271             * @param uuid the uuid
272             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
273             * @return the first matching journal article
274             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
275             * @throws SystemException if a system exception occurred
276             */
277            public JournalArticle findByUuid_First(String uuid,
278                    OrderByComparator orderByComparator)
279                    throws NoSuchArticleException, SystemException {
280                    JournalArticle journalArticle = fetchByUuid_First(uuid,
281                                    orderByComparator);
282    
283                    if (journalArticle != null) {
284                            return journalArticle;
285                    }
286    
287                    StringBundler msg = new StringBundler(4);
288    
289                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
290    
291                    msg.append("uuid=");
292                    msg.append(uuid);
293    
294                    msg.append(StringPool.CLOSE_CURLY_BRACE);
295    
296                    throw new NoSuchArticleException(msg.toString());
297            }
298    
299            /**
300             * Returns the first journal article in the ordered set where uuid = &#63;.
301             *
302             * @param uuid the uuid
303             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
304             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
305             * @throws SystemException if a system exception occurred
306             */
307            public JournalArticle fetchByUuid_First(String uuid,
308                    OrderByComparator orderByComparator) throws SystemException {
309                    List<JournalArticle> list = findByUuid(uuid, 0, 1, orderByComparator);
310    
311                    if (!list.isEmpty()) {
312                            return list.get(0);
313                    }
314    
315                    return null;
316            }
317    
318            /**
319             * Returns the last journal article in the ordered set where uuid = &#63;.
320             *
321             * @param uuid the uuid
322             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
323             * @return the last matching journal article
324             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
325             * @throws SystemException if a system exception occurred
326             */
327            public JournalArticle findByUuid_Last(String uuid,
328                    OrderByComparator orderByComparator)
329                    throws NoSuchArticleException, SystemException {
330                    JournalArticle journalArticle = fetchByUuid_Last(uuid, orderByComparator);
331    
332                    if (journalArticle != null) {
333                            return journalArticle;
334                    }
335    
336                    StringBundler msg = new StringBundler(4);
337    
338                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
339    
340                    msg.append("uuid=");
341                    msg.append(uuid);
342    
343                    msg.append(StringPool.CLOSE_CURLY_BRACE);
344    
345                    throw new NoSuchArticleException(msg.toString());
346            }
347    
348            /**
349             * Returns the last journal article in the ordered set where uuid = &#63;.
350             *
351             * @param uuid the uuid
352             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
353             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
354             * @throws SystemException if a system exception occurred
355             */
356            public JournalArticle fetchByUuid_Last(String uuid,
357                    OrderByComparator orderByComparator) throws SystemException {
358                    int count = countByUuid(uuid);
359    
360                    List<JournalArticle> list = findByUuid(uuid, count - 1, count,
361                                    orderByComparator);
362    
363                    if (!list.isEmpty()) {
364                            return list.get(0);
365                    }
366    
367                    return null;
368            }
369    
370            /**
371             * Returns the journal articles before and after the current journal article in the ordered set where uuid = &#63;.
372             *
373             * @param id the primary key of the current journal article
374             * @param uuid the uuid
375             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
376             * @return the previous, current, and next journal article
377             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
378             * @throws SystemException if a system exception occurred
379             */
380            public JournalArticle[] findByUuid_PrevAndNext(long id, String uuid,
381                    OrderByComparator orderByComparator)
382                    throws NoSuchArticleException, SystemException {
383                    JournalArticle journalArticle = findByPrimaryKey(id);
384    
385                    Session session = null;
386    
387                    try {
388                            session = openSession();
389    
390                            JournalArticle[] array = new JournalArticleImpl[3];
391    
392                            array[0] = getByUuid_PrevAndNext(session, journalArticle, uuid,
393                                            orderByComparator, true);
394    
395                            array[1] = journalArticle;
396    
397                            array[2] = getByUuid_PrevAndNext(session, journalArticle, uuid,
398                                            orderByComparator, false);
399    
400                            return array;
401                    }
402                    catch (Exception e) {
403                            throw processException(e);
404                    }
405                    finally {
406                            closeSession(session);
407                    }
408            }
409    
410            protected JournalArticle getByUuid_PrevAndNext(Session session,
411                    JournalArticle journalArticle, String uuid,
412                    OrderByComparator orderByComparator, boolean previous) {
413                    StringBundler query = null;
414    
415                    if (orderByComparator != null) {
416                            query = new StringBundler(6 +
417                                            (orderByComparator.getOrderByFields().length * 6));
418                    }
419                    else {
420                            query = new StringBundler(3);
421                    }
422    
423                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
424    
425                    boolean bindUuid = false;
426    
427                    if (uuid == null) {
428                            query.append(_FINDER_COLUMN_UUID_UUID_1);
429                    }
430                    else if (uuid.equals(StringPool.BLANK)) {
431                            query.append(_FINDER_COLUMN_UUID_UUID_3);
432                    }
433                    else {
434                            bindUuid = true;
435    
436                            query.append(_FINDER_COLUMN_UUID_UUID_2);
437                    }
438    
439                    if (orderByComparator != null) {
440                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
441    
442                            if (orderByConditionFields.length > 0) {
443                                    query.append(WHERE_AND);
444                            }
445    
446                            for (int i = 0; i < orderByConditionFields.length; i++) {
447                                    query.append(_ORDER_BY_ENTITY_ALIAS);
448                                    query.append(orderByConditionFields[i]);
449    
450                                    if ((i + 1) < orderByConditionFields.length) {
451                                            if (orderByComparator.isAscending() ^ previous) {
452                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
453                                            }
454                                            else {
455                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
456                                            }
457                                    }
458                                    else {
459                                            if (orderByComparator.isAscending() ^ previous) {
460                                                    query.append(WHERE_GREATER_THAN);
461                                            }
462                                            else {
463                                                    query.append(WHERE_LESSER_THAN);
464                                            }
465                                    }
466                            }
467    
468                            query.append(ORDER_BY_CLAUSE);
469    
470                            String[] orderByFields = orderByComparator.getOrderByFields();
471    
472                            for (int i = 0; i < orderByFields.length; i++) {
473                                    query.append(_ORDER_BY_ENTITY_ALIAS);
474                                    query.append(orderByFields[i]);
475    
476                                    if ((i + 1) < orderByFields.length) {
477                                            if (orderByComparator.isAscending() ^ previous) {
478                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
479                                            }
480                                            else {
481                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
482                                            }
483                                    }
484                                    else {
485                                            if (orderByComparator.isAscending() ^ previous) {
486                                                    query.append(ORDER_BY_ASC);
487                                            }
488                                            else {
489                                                    query.append(ORDER_BY_DESC);
490                                            }
491                                    }
492                            }
493                    }
494                    else {
495                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
496                    }
497    
498                    String sql = query.toString();
499    
500                    Query q = session.createQuery(sql);
501    
502                    q.setFirstResult(0);
503                    q.setMaxResults(2);
504    
505                    QueryPos qPos = QueryPos.getInstance(q);
506    
507                    if (bindUuid) {
508                            qPos.add(uuid);
509                    }
510    
511                    if (orderByComparator != null) {
512                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
513    
514                            for (Object value : values) {
515                                    qPos.add(value);
516                            }
517                    }
518    
519                    List<JournalArticle> list = q.list();
520    
521                    if (list.size() == 2) {
522                            return list.get(1);
523                    }
524                    else {
525                            return null;
526                    }
527            }
528    
529            /**
530             * Removes all the journal articles where uuid = &#63; from the database.
531             *
532             * @param uuid the uuid
533             * @throws SystemException if a system exception occurred
534             */
535            public void removeByUuid(String uuid) throws SystemException {
536                    for (JournalArticle journalArticle : findByUuid(uuid,
537                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
538                            remove(journalArticle);
539                    }
540            }
541    
542            /**
543             * Returns the number of journal articles where uuid = &#63;.
544             *
545             * @param uuid the uuid
546             * @return the number of matching journal articles
547             * @throws SystemException if a system exception occurred
548             */
549            public int countByUuid(String uuid) throws SystemException {
550                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
551    
552                    Object[] finderArgs = new Object[] { uuid };
553    
554                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
555                                    this);
556    
557                    if (count == null) {
558                            StringBundler query = new StringBundler(2);
559    
560                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
561    
562                            boolean bindUuid = false;
563    
564                            if (uuid == null) {
565                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
566                            }
567                            else if (uuid.equals(StringPool.BLANK)) {
568                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
569                            }
570                            else {
571                                    bindUuid = true;
572    
573                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
574                            }
575    
576                            String sql = query.toString();
577    
578                            Session session = null;
579    
580                            try {
581                                    session = openSession();
582    
583                                    Query q = session.createQuery(sql);
584    
585                                    QueryPos qPos = QueryPos.getInstance(q);
586    
587                                    if (bindUuid) {
588                                            qPos.add(uuid);
589                                    }
590    
591                                    count = (Long)q.uniqueResult();
592    
593                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
594                            }
595                            catch (Exception e) {
596                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
597    
598                                    throw processException(e);
599                            }
600                            finally {
601                                    closeSession(session);
602                            }
603                    }
604    
605                    return count.intValue();
606            }
607    
608            private static final String _FINDER_COLUMN_UUID_UUID_1 = "journalArticle.uuid IS NULL";
609            private static final String _FINDER_COLUMN_UUID_UUID_2 = "journalArticle.uuid = ?";
610            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = '')";
611            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
612                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
613                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY,
614                            "fetchByUUID_G",
615                            new String[] { String.class.getName(), Long.class.getName() },
616                            JournalArticleModelImpl.UUID_COLUMN_BITMASK |
617                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK);
618            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
619                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
620                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
621                            new String[] { String.class.getName(), Long.class.getName() });
622    
623            /**
624             * 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.
625             *
626             * @param uuid the uuid
627             * @param groupId the group ID
628             * @return the matching journal article
629             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
630             * @throws SystemException if a system exception occurred
631             */
632            public JournalArticle findByUUID_G(String uuid, long groupId)
633                    throws NoSuchArticleException, SystemException {
634                    JournalArticle journalArticle = fetchByUUID_G(uuid, groupId);
635    
636                    if (journalArticle == null) {
637                            StringBundler msg = new StringBundler(6);
638    
639                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
640    
641                            msg.append("uuid=");
642                            msg.append(uuid);
643    
644                            msg.append(", groupId=");
645                            msg.append(groupId);
646    
647                            msg.append(StringPool.CLOSE_CURLY_BRACE);
648    
649                            if (_log.isWarnEnabled()) {
650                                    _log.warn(msg.toString());
651                            }
652    
653                            throw new NoSuchArticleException(msg.toString());
654                    }
655    
656                    return journalArticle;
657            }
658    
659            /**
660             * 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.
661             *
662             * @param uuid the uuid
663             * @param groupId the group ID
664             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
665             * @throws SystemException if a system exception occurred
666             */
667            public JournalArticle fetchByUUID_G(String uuid, long groupId)
668                    throws SystemException {
669                    return fetchByUUID_G(uuid, groupId, true);
670            }
671    
672            /**
673             * 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.
674             *
675             * @param uuid the uuid
676             * @param groupId the group ID
677             * @param retrieveFromCache whether to use the finder cache
678             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
679             * @throws SystemException if a system exception occurred
680             */
681            public JournalArticle fetchByUUID_G(String uuid, long groupId,
682                    boolean retrieveFromCache) throws SystemException {
683                    Object[] finderArgs = new Object[] { uuid, groupId };
684    
685                    Object result = null;
686    
687                    if (retrieveFromCache) {
688                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
689                                            finderArgs, this);
690                    }
691    
692                    if (result instanceof JournalArticle) {
693                            JournalArticle journalArticle = (JournalArticle)result;
694    
695                            if (!Validator.equals(uuid, journalArticle.getUuid()) ||
696                                            (groupId != journalArticle.getGroupId())) {
697                                    result = null;
698                            }
699                    }
700    
701                    if (result == null) {
702                            StringBundler query = new StringBundler(4);
703    
704                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
705    
706                            boolean bindUuid = false;
707    
708                            if (uuid == null) {
709                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
710                            }
711                            else if (uuid.equals(StringPool.BLANK)) {
712                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
713                            }
714                            else {
715                                    bindUuid = true;
716    
717                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
718                            }
719    
720                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
721    
722                            String sql = query.toString();
723    
724                            Session session = null;
725    
726                            try {
727                                    session = openSession();
728    
729                                    Query q = session.createQuery(sql);
730    
731                                    QueryPos qPos = QueryPos.getInstance(q);
732    
733                                    if (bindUuid) {
734                                            qPos.add(uuid);
735                                    }
736    
737                                    qPos.add(groupId);
738    
739                                    List<JournalArticle> list = q.list();
740    
741                                    if (list.isEmpty()) {
742                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
743                                                    finderArgs, list);
744                                    }
745                                    else {
746                                            JournalArticle journalArticle = list.get(0);
747    
748                                            result = journalArticle;
749    
750                                            cacheResult(journalArticle);
751    
752                                            if ((journalArticle.getUuid() == null) ||
753                                                            !journalArticle.getUuid().equals(uuid) ||
754                                                            (journalArticle.getGroupId() != groupId)) {
755                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
756                                                            finderArgs, journalArticle);
757                                            }
758                                    }
759                            }
760                            catch (Exception e) {
761                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
762                                            finderArgs);
763    
764                                    throw processException(e);
765                            }
766                            finally {
767                                    closeSession(session);
768                            }
769                    }
770    
771                    if (result instanceof List<?>) {
772                            return null;
773                    }
774                    else {
775                            return (JournalArticle)result;
776                    }
777            }
778    
779            /**
780             * Removes the journal article where uuid = &#63; and groupId = &#63; from the database.
781             *
782             * @param uuid the uuid
783             * @param groupId the group ID
784             * @return the journal article that was removed
785             * @throws SystemException if a system exception occurred
786             */
787            public JournalArticle removeByUUID_G(String uuid, long groupId)
788                    throws NoSuchArticleException, SystemException {
789                    JournalArticle journalArticle = findByUUID_G(uuid, groupId);
790    
791                    return remove(journalArticle);
792            }
793    
794            /**
795             * Returns the number of journal articles where uuid = &#63; and groupId = &#63;.
796             *
797             * @param uuid the uuid
798             * @param groupId the group ID
799             * @return the number of matching journal articles
800             * @throws SystemException if a system exception occurred
801             */
802            public int countByUUID_G(String uuid, long groupId)
803                    throws SystemException {
804                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
805    
806                    Object[] finderArgs = new Object[] { uuid, groupId };
807    
808                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
809                                    this);
810    
811                    if (count == null) {
812                            StringBundler query = new StringBundler(3);
813    
814                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
815    
816                            boolean bindUuid = false;
817    
818                            if (uuid == null) {
819                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
820                            }
821                            else if (uuid.equals(StringPool.BLANK)) {
822                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
823                            }
824                            else {
825                                    bindUuid = true;
826    
827                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
828                            }
829    
830                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
831    
832                            String sql = query.toString();
833    
834                            Session session = null;
835    
836                            try {
837                                    session = openSession();
838    
839                                    Query q = session.createQuery(sql);
840    
841                                    QueryPos qPos = QueryPos.getInstance(q);
842    
843                                    if (bindUuid) {
844                                            qPos.add(uuid);
845                                    }
846    
847                                    qPos.add(groupId);
848    
849                                    count = (Long)q.uniqueResult();
850    
851                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
852                            }
853                            catch (Exception e) {
854                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
855    
856                                    throw processException(e);
857                            }
858                            finally {
859                                    closeSession(session);
860                            }
861                    }
862    
863                    return count.intValue();
864            }
865    
866            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "journalArticle.uuid IS NULL AND ";
867            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "journalArticle.uuid = ? AND ";
868            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = '') AND ";
869            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "journalArticle.groupId = ?";
870            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
871                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
872                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
873                            "findByUuid_C",
874                            new String[] {
875                                    String.class.getName(), Long.class.getName(),
876                                    
877                            Integer.class.getName(), Integer.class.getName(),
878                                    OrderByComparator.class.getName()
879                            });
880            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
881                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
882                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
883                            JournalArticleImpl.class,
884                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
885                            new String[] { String.class.getName(), Long.class.getName() },
886                            JournalArticleModelImpl.UUID_COLUMN_BITMASK |
887                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
888                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
889                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
890            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
891                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
892                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
893                            new String[] { String.class.getName(), Long.class.getName() });
894    
895            /**
896             * Returns all the journal articles where uuid = &#63; and companyId = &#63;.
897             *
898             * @param uuid the uuid
899             * @param companyId the company ID
900             * @return the matching journal articles
901             * @throws SystemException if a system exception occurred
902             */
903            public List<JournalArticle> findByUuid_C(String uuid, long companyId)
904                    throws SystemException {
905                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
906                            QueryUtil.ALL_POS, null);
907            }
908    
909            /**
910             * Returns a range of all the journal articles where uuid = &#63; and companyId = &#63;.
911             *
912             * <p>
913             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
914             * </p>
915             *
916             * @param uuid the uuid
917             * @param companyId the company ID
918             * @param start the lower bound of the range of journal articles
919             * @param end the upper bound of the range of journal articles (not inclusive)
920             * @return the range of matching journal articles
921             * @throws SystemException if a system exception occurred
922             */
923            public List<JournalArticle> findByUuid_C(String uuid, long companyId,
924                    int start, int end) throws SystemException {
925                    return findByUuid_C(uuid, companyId, start, end, null);
926            }
927    
928            /**
929             * Returns an ordered range of all the journal articles where uuid = &#63; and companyId = &#63;.
930             *
931             * <p>
932             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
933             * </p>
934             *
935             * @param uuid the uuid
936             * @param companyId the company ID
937             * @param start the lower bound of the range of journal articles
938             * @param end the upper bound of the range of journal articles (not inclusive)
939             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
940             * @return the ordered range of matching journal articles
941             * @throws SystemException if a system exception occurred
942             */
943            public List<JournalArticle> findByUuid_C(String uuid, long companyId,
944                    int start, int end, OrderByComparator orderByComparator)
945                    throws SystemException {
946                    boolean pagination = true;
947                    FinderPath finderPath = null;
948                    Object[] finderArgs = null;
949    
950                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
951                                    (orderByComparator == null)) {
952                            pagination = false;
953                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
954                            finderArgs = new Object[] { uuid, companyId };
955                    }
956                    else {
957                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
958                            finderArgs = new Object[] {
959                                            uuid, companyId,
960                                            
961                                            start, end, orderByComparator
962                                    };
963                    }
964    
965                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
966                                    finderArgs, this);
967    
968                    if ((list != null) && !list.isEmpty()) {
969                            for (JournalArticle journalArticle : list) {
970                                    if (!Validator.equals(uuid, journalArticle.getUuid()) ||
971                                                    (companyId != journalArticle.getCompanyId())) {
972                                            list = null;
973    
974                                            break;
975                                    }
976                            }
977                    }
978    
979                    if (list == null) {
980                            StringBundler query = null;
981    
982                            if (orderByComparator != null) {
983                                    query = new StringBundler(4 +
984                                                    (orderByComparator.getOrderByFields().length * 3));
985                            }
986                            else {
987                                    query = new StringBundler(4);
988                            }
989    
990                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
991    
992                            boolean bindUuid = false;
993    
994                            if (uuid == null) {
995                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
996                            }
997                            else if (uuid.equals(StringPool.BLANK)) {
998                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
999                            }
1000                            else {
1001                                    bindUuid = true;
1002    
1003                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1004                            }
1005    
1006                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1007    
1008                            if (orderByComparator != null) {
1009                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1010                                            orderByComparator);
1011                            }
1012                            else
1013                             if (pagination) {
1014                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1015                            }
1016    
1017                            String sql = query.toString();
1018    
1019                            Session session = null;
1020    
1021                            try {
1022                                    session = openSession();
1023    
1024                                    Query q = session.createQuery(sql);
1025    
1026                                    QueryPos qPos = QueryPos.getInstance(q);
1027    
1028                                    if (bindUuid) {
1029                                            qPos.add(uuid);
1030                                    }
1031    
1032                                    qPos.add(companyId);
1033    
1034                                    if (!pagination) {
1035                                            list = (List<JournalArticle>)QueryUtil.list(q,
1036                                                            getDialect(), start, end, false);
1037    
1038                                            Collections.sort(list);
1039    
1040                                            list = new UnmodifiableList<JournalArticle>(list);
1041                                    }
1042                                    else {
1043                                            list = (List<JournalArticle>)QueryUtil.list(q,
1044                                                            getDialect(), start, end);
1045                                    }
1046    
1047                                    cacheResult(list);
1048    
1049                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1050                            }
1051                            catch (Exception e) {
1052                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1053    
1054                                    throw processException(e);
1055                            }
1056                            finally {
1057                                    closeSession(session);
1058                            }
1059                    }
1060    
1061                    return list;
1062            }
1063    
1064            /**
1065             * Returns the first journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1066             *
1067             * @param uuid the uuid
1068             * @param companyId the company ID
1069             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1070             * @return the first matching journal article
1071             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1072             * @throws SystemException if a system exception occurred
1073             */
1074            public JournalArticle findByUuid_C_First(String uuid, long companyId,
1075                    OrderByComparator orderByComparator)
1076                    throws NoSuchArticleException, SystemException {
1077                    JournalArticle journalArticle = fetchByUuid_C_First(uuid, companyId,
1078                                    orderByComparator);
1079    
1080                    if (journalArticle != null) {
1081                            return journalArticle;
1082                    }
1083    
1084                    StringBundler msg = new StringBundler(6);
1085    
1086                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1087    
1088                    msg.append("uuid=");
1089                    msg.append(uuid);
1090    
1091                    msg.append(", companyId=");
1092                    msg.append(companyId);
1093    
1094                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1095    
1096                    throw new NoSuchArticleException(msg.toString());
1097            }
1098    
1099            /**
1100             * Returns the first journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1101             *
1102             * @param uuid the uuid
1103             * @param companyId the company ID
1104             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1105             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
1106             * @throws SystemException if a system exception occurred
1107             */
1108            public JournalArticle fetchByUuid_C_First(String uuid, long companyId,
1109                    OrderByComparator orderByComparator) throws SystemException {
1110                    List<JournalArticle> list = findByUuid_C(uuid, companyId, 0, 1,
1111                                    orderByComparator);
1112    
1113                    if (!list.isEmpty()) {
1114                            return list.get(0);
1115                    }
1116    
1117                    return null;
1118            }
1119    
1120            /**
1121             * Returns the last journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1122             *
1123             * @param uuid the uuid
1124             * @param companyId the company ID
1125             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1126             * @return the last matching journal article
1127             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1128             * @throws SystemException if a system exception occurred
1129             */
1130            public JournalArticle findByUuid_C_Last(String uuid, long companyId,
1131                    OrderByComparator orderByComparator)
1132                    throws NoSuchArticleException, SystemException {
1133                    JournalArticle journalArticle = fetchByUuid_C_Last(uuid, companyId,
1134                                    orderByComparator);
1135    
1136                    if (journalArticle != null) {
1137                            return journalArticle;
1138                    }
1139    
1140                    StringBundler msg = new StringBundler(6);
1141    
1142                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1143    
1144                    msg.append("uuid=");
1145                    msg.append(uuid);
1146    
1147                    msg.append(", companyId=");
1148                    msg.append(companyId);
1149    
1150                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1151    
1152                    throw new NoSuchArticleException(msg.toString());
1153            }
1154    
1155            /**
1156             * Returns the last journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1157             *
1158             * @param uuid the uuid
1159             * @param companyId the company ID
1160             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1161             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
1162             * @throws SystemException if a system exception occurred
1163             */
1164            public JournalArticle fetchByUuid_C_Last(String uuid, long companyId,
1165                    OrderByComparator orderByComparator) throws SystemException {
1166                    int count = countByUuid_C(uuid, companyId);
1167    
1168                    List<JournalArticle> list = findByUuid_C(uuid, companyId, count - 1,
1169                                    count, orderByComparator);
1170    
1171                    if (!list.isEmpty()) {
1172                            return list.get(0);
1173                    }
1174    
1175                    return null;
1176            }
1177    
1178            /**
1179             * Returns the journal articles before and after the current journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1180             *
1181             * @param id the primary key of the current journal article
1182             * @param uuid the uuid
1183             * @param companyId the company ID
1184             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1185             * @return the previous, current, and next journal article
1186             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
1187             * @throws SystemException if a system exception occurred
1188             */
1189            public JournalArticle[] findByUuid_C_PrevAndNext(long id, String uuid,
1190                    long companyId, OrderByComparator orderByComparator)
1191                    throws NoSuchArticleException, SystemException {
1192                    JournalArticle journalArticle = findByPrimaryKey(id);
1193    
1194                    Session session = null;
1195    
1196                    try {
1197                            session = openSession();
1198    
1199                            JournalArticle[] array = new JournalArticleImpl[3];
1200    
1201                            array[0] = getByUuid_C_PrevAndNext(session, journalArticle, uuid,
1202                                            companyId, orderByComparator, true);
1203    
1204                            array[1] = journalArticle;
1205    
1206                            array[2] = getByUuid_C_PrevAndNext(session, journalArticle, uuid,
1207                                            companyId, orderByComparator, false);
1208    
1209                            return array;
1210                    }
1211                    catch (Exception e) {
1212                            throw processException(e);
1213                    }
1214                    finally {
1215                            closeSession(session);
1216                    }
1217            }
1218    
1219            protected JournalArticle getByUuid_C_PrevAndNext(Session session,
1220                    JournalArticle journalArticle, String uuid, long companyId,
1221                    OrderByComparator orderByComparator, boolean previous) {
1222                    StringBundler query = null;
1223    
1224                    if (orderByComparator != null) {
1225                            query = new StringBundler(6 +
1226                                            (orderByComparator.getOrderByFields().length * 6));
1227                    }
1228                    else {
1229                            query = new StringBundler(3);
1230                    }
1231    
1232                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1233    
1234                    boolean bindUuid = false;
1235    
1236                    if (uuid == null) {
1237                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1238                    }
1239                    else if (uuid.equals(StringPool.BLANK)) {
1240                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1241                    }
1242                    else {
1243                            bindUuid = true;
1244    
1245                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1246                    }
1247    
1248                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1249    
1250                    if (orderByComparator != null) {
1251                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1252    
1253                            if (orderByConditionFields.length > 0) {
1254                                    query.append(WHERE_AND);
1255                            }
1256    
1257                            for (int i = 0; i < orderByConditionFields.length; i++) {
1258                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1259                                    query.append(orderByConditionFields[i]);
1260    
1261                                    if ((i + 1) < orderByConditionFields.length) {
1262                                            if (orderByComparator.isAscending() ^ previous) {
1263                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1264                                            }
1265                                            else {
1266                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1267                                            }
1268                                    }
1269                                    else {
1270                                            if (orderByComparator.isAscending() ^ previous) {
1271                                                    query.append(WHERE_GREATER_THAN);
1272                                            }
1273                                            else {
1274                                                    query.append(WHERE_LESSER_THAN);
1275                                            }
1276                                    }
1277                            }
1278    
1279                            query.append(ORDER_BY_CLAUSE);
1280    
1281                            String[] orderByFields = orderByComparator.getOrderByFields();
1282    
1283                            for (int i = 0; i < orderByFields.length; i++) {
1284                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1285                                    query.append(orderByFields[i]);
1286    
1287                                    if ((i + 1) < orderByFields.length) {
1288                                            if (orderByComparator.isAscending() ^ previous) {
1289                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1290                                            }
1291                                            else {
1292                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1293                                            }
1294                                    }
1295                                    else {
1296                                            if (orderByComparator.isAscending() ^ previous) {
1297                                                    query.append(ORDER_BY_ASC);
1298                                            }
1299                                            else {
1300                                                    query.append(ORDER_BY_DESC);
1301                                            }
1302                                    }
1303                            }
1304                    }
1305                    else {
1306                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1307                    }
1308    
1309                    String sql = query.toString();
1310    
1311                    Query q = session.createQuery(sql);
1312    
1313                    q.setFirstResult(0);
1314                    q.setMaxResults(2);
1315    
1316                    QueryPos qPos = QueryPos.getInstance(q);
1317    
1318                    if (bindUuid) {
1319                            qPos.add(uuid);
1320                    }
1321    
1322                    qPos.add(companyId);
1323    
1324                    if (orderByComparator != null) {
1325                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
1326    
1327                            for (Object value : values) {
1328                                    qPos.add(value);
1329                            }
1330                    }
1331    
1332                    List<JournalArticle> list = q.list();
1333    
1334                    if (list.size() == 2) {
1335                            return list.get(1);
1336                    }
1337                    else {
1338                            return null;
1339                    }
1340            }
1341    
1342            /**
1343             * Removes all the journal articles where uuid = &#63; and companyId = &#63; from the database.
1344             *
1345             * @param uuid the uuid
1346             * @param companyId the company ID
1347             * @throws SystemException if a system exception occurred
1348             */
1349            public void removeByUuid_C(String uuid, long companyId)
1350                    throws SystemException {
1351                    for (JournalArticle journalArticle : findByUuid_C(uuid, companyId,
1352                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1353                            remove(journalArticle);
1354                    }
1355            }
1356    
1357            /**
1358             * Returns the number of journal articles where uuid = &#63; and companyId = &#63;.
1359             *
1360             * @param uuid the uuid
1361             * @param companyId the company ID
1362             * @return the number of matching journal articles
1363             * @throws SystemException if a system exception occurred
1364             */
1365            public int countByUuid_C(String uuid, long companyId)
1366                    throws SystemException {
1367                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1368    
1369                    Object[] finderArgs = new Object[] { uuid, companyId };
1370    
1371                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1372                                    this);
1373    
1374                    if (count == null) {
1375                            StringBundler query = new StringBundler(3);
1376    
1377                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
1378    
1379                            boolean bindUuid = false;
1380    
1381                            if (uuid == null) {
1382                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1383                            }
1384                            else if (uuid.equals(StringPool.BLANK)) {
1385                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1386                            }
1387                            else {
1388                                    bindUuid = true;
1389    
1390                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1391                            }
1392    
1393                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1394    
1395                            String sql = query.toString();
1396    
1397                            Session session = null;
1398    
1399                            try {
1400                                    session = openSession();
1401    
1402                                    Query q = session.createQuery(sql);
1403    
1404                                    QueryPos qPos = QueryPos.getInstance(q);
1405    
1406                                    if (bindUuid) {
1407                                            qPos.add(uuid);
1408                                    }
1409    
1410                                    qPos.add(companyId);
1411    
1412                                    count = (Long)q.uniqueResult();
1413    
1414                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1415                            }
1416                            catch (Exception e) {
1417                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1418    
1419                                    throw processException(e);
1420                            }
1421                            finally {
1422                                    closeSession(session);
1423                            }
1424                    }
1425    
1426                    return count.intValue();
1427            }
1428    
1429            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "journalArticle.uuid IS NULL AND ";
1430            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "journalArticle.uuid = ? AND ";
1431            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = '') AND ";
1432            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "journalArticle.companyId = ?";
1433            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEPRIMKEY =
1434                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1435                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
1436                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1437                            "findByResourcePrimKey",
1438                            new String[] {
1439                                    Long.class.getName(),
1440                                    
1441                            Integer.class.getName(), Integer.class.getName(),
1442                                    OrderByComparator.class.getName()
1443                            });
1444            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY =
1445                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1446                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
1447                            JournalArticleImpl.class,
1448                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByResourcePrimKey",
1449                            new String[] { Long.class.getName() },
1450                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
1451                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
1452                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
1453            public static final FinderPath FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1454                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
1455                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
1456                            "countByResourcePrimKey", new String[] { Long.class.getName() });
1457    
1458            /**
1459             * Returns all the journal articles where resourcePrimKey = &#63;.
1460             *
1461             * @param resourcePrimKey the resource prim key
1462             * @return the matching journal articles
1463             * @throws SystemException if a system exception occurred
1464             */
1465            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey)
1466                    throws SystemException {
1467                    return findByResourcePrimKey(resourcePrimKey, QueryUtil.ALL_POS,
1468                            QueryUtil.ALL_POS, null);
1469            }
1470    
1471            /**
1472             * Returns a range of all the journal articles where resourcePrimKey = &#63;.
1473             *
1474             * <p>
1475             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1476             * </p>
1477             *
1478             * @param resourcePrimKey the resource prim key
1479             * @param start the lower bound of the range of journal articles
1480             * @param end the upper bound of the range of journal articles (not inclusive)
1481             * @return the range of matching journal articles
1482             * @throws SystemException if a system exception occurred
1483             */
1484            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey,
1485                    int start, int end) throws SystemException {
1486                    return findByResourcePrimKey(resourcePrimKey, start, end, null);
1487            }
1488    
1489            /**
1490             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63;.
1491             *
1492             * <p>
1493             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1494             * </p>
1495             *
1496             * @param resourcePrimKey the resource prim key
1497             * @param start the lower bound of the range of journal articles
1498             * @param end the upper bound of the range of journal articles (not inclusive)
1499             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1500             * @return the ordered range of matching journal articles
1501             * @throws SystemException if a system exception occurred
1502             */
1503            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey,
1504                    int start, int end, OrderByComparator orderByComparator)
1505                    throws SystemException {
1506                    boolean pagination = true;
1507                    FinderPath finderPath = null;
1508                    Object[] finderArgs = null;
1509    
1510                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1511                                    (orderByComparator == null)) {
1512                            pagination = false;
1513                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY;
1514                            finderArgs = new Object[] { resourcePrimKey };
1515                    }
1516                    else {
1517                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEPRIMKEY;
1518                            finderArgs = new Object[] {
1519                                            resourcePrimKey,
1520                                            
1521                                            start, end, orderByComparator
1522                                    };
1523                    }
1524    
1525                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
1526                                    finderArgs, this);
1527    
1528                    if ((list != null) && !list.isEmpty()) {
1529                            for (JournalArticle journalArticle : list) {
1530                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey())) {
1531                                            list = null;
1532    
1533                                            break;
1534                                    }
1535                            }
1536                    }
1537    
1538                    if (list == null) {
1539                            StringBundler query = null;
1540    
1541                            if (orderByComparator != null) {
1542                                    query = new StringBundler(3 +
1543                                                    (orderByComparator.getOrderByFields().length * 3));
1544                            }
1545                            else {
1546                                    query = new StringBundler(3);
1547                            }
1548    
1549                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1550    
1551                            query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
1552    
1553                            if (orderByComparator != null) {
1554                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1555                                            orderByComparator);
1556                            }
1557                            else
1558                             if (pagination) {
1559                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1560                            }
1561    
1562                            String sql = query.toString();
1563    
1564                            Session session = null;
1565    
1566                            try {
1567                                    session = openSession();
1568    
1569                                    Query q = session.createQuery(sql);
1570    
1571                                    QueryPos qPos = QueryPos.getInstance(q);
1572    
1573                                    qPos.add(resourcePrimKey);
1574    
1575                                    if (!pagination) {
1576                                            list = (List<JournalArticle>)QueryUtil.list(q,
1577                                                            getDialect(), start, end, false);
1578    
1579                                            Collections.sort(list);
1580    
1581                                            list = new UnmodifiableList<JournalArticle>(list);
1582                                    }
1583                                    else {
1584                                            list = (List<JournalArticle>)QueryUtil.list(q,
1585                                                            getDialect(), start, end);
1586                                    }
1587    
1588                                    cacheResult(list);
1589    
1590                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1591                            }
1592                            catch (Exception e) {
1593                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1594    
1595                                    throw processException(e);
1596                            }
1597                            finally {
1598                                    closeSession(session);
1599                            }
1600                    }
1601    
1602                    return list;
1603            }
1604    
1605            /**
1606             * Returns the first journal article in the ordered set where resourcePrimKey = &#63;.
1607             *
1608             * @param resourcePrimKey the resource prim key
1609             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1610             * @return the first matching journal article
1611             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1612             * @throws SystemException if a system exception occurred
1613             */
1614            public JournalArticle findByResourcePrimKey_First(long resourcePrimKey,
1615                    OrderByComparator orderByComparator)
1616                    throws NoSuchArticleException, SystemException {
1617                    JournalArticle journalArticle = fetchByResourcePrimKey_First(resourcePrimKey,
1618                                    orderByComparator);
1619    
1620                    if (journalArticle != null) {
1621                            return journalArticle;
1622                    }
1623    
1624                    StringBundler msg = new StringBundler(4);
1625    
1626                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1627    
1628                    msg.append("resourcePrimKey=");
1629                    msg.append(resourcePrimKey);
1630    
1631                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1632    
1633                    throw new NoSuchArticleException(msg.toString());
1634            }
1635    
1636            /**
1637             * Returns the first journal article in the ordered set where resourcePrimKey = &#63;.
1638             *
1639             * @param resourcePrimKey the resource prim key
1640             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1641             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
1642             * @throws SystemException if a system exception occurred
1643             */
1644            public JournalArticle fetchByResourcePrimKey_First(long resourcePrimKey,
1645                    OrderByComparator orderByComparator) throws SystemException {
1646                    List<JournalArticle> list = findByResourcePrimKey(resourcePrimKey, 0,
1647                                    1, orderByComparator);
1648    
1649                    if (!list.isEmpty()) {
1650                            return list.get(0);
1651                    }
1652    
1653                    return null;
1654            }
1655    
1656            /**
1657             * Returns the last journal article in the ordered set where resourcePrimKey = &#63;.
1658             *
1659             * @param resourcePrimKey the resource prim key
1660             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1661             * @return the last matching journal article
1662             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1663             * @throws SystemException if a system exception occurred
1664             */
1665            public JournalArticle findByResourcePrimKey_Last(long resourcePrimKey,
1666                    OrderByComparator orderByComparator)
1667                    throws NoSuchArticleException, SystemException {
1668                    JournalArticle journalArticle = fetchByResourcePrimKey_Last(resourcePrimKey,
1669                                    orderByComparator);
1670    
1671                    if (journalArticle != null) {
1672                            return journalArticle;
1673                    }
1674    
1675                    StringBundler msg = new StringBundler(4);
1676    
1677                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1678    
1679                    msg.append("resourcePrimKey=");
1680                    msg.append(resourcePrimKey);
1681    
1682                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1683    
1684                    throw new NoSuchArticleException(msg.toString());
1685            }
1686    
1687            /**
1688             * Returns the last journal article in the ordered set where resourcePrimKey = &#63;.
1689             *
1690             * @param resourcePrimKey the resource prim key
1691             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1692             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
1693             * @throws SystemException if a system exception occurred
1694             */
1695            public JournalArticle fetchByResourcePrimKey_Last(long resourcePrimKey,
1696                    OrderByComparator orderByComparator) throws SystemException {
1697                    int count = countByResourcePrimKey(resourcePrimKey);
1698    
1699                    List<JournalArticle> list = findByResourcePrimKey(resourcePrimKey,
1700                                    count - 1, count, orderByComparator);
1701    
1702                    if (!list.isEmpty()) {
1703                            return list.get(0);
1704                    }
1705    
1706                    return null;
1707            }
1708    
1709            /**
1710             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63;.
1711             *
1712             * @param id the primary key of the current journal article
1713             * @param resourcePrimKey the resource prim key
1714             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1715             * @return the previous, current, and next journal article
1716             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
1717             * @throws SystemException if a system exception occurred
1718             */
1719            public JournalArticle[] findByResourcePrimKey_PrevAndNext(long id,
1720                    long resourcePrimKey, OrderByComparator orderByComparator)
1721                    throws NoSuchArticleException, SystemException {
1722                    JournalArticle journalArticle = findByPrimaryKey(id);
1723    
1724                    Session session = null;
1725    
1726                    try {
1727                            session = openSession();
1728    
1729                            JournalArticle[] array = new JournalArticleImpl[3];
1730    
1731                            array[0] = getByResourcePrimKey_PrevAndNext(session,
1732                                            journalArticle, resourcePrimKey, orderByComparator, true);
1733    
1734                            array[1] = journalArticle;
1735    
1736                            array[2] = getByResourcePrimKey_PrevAndNext(session,
1737                                            journalArticle, resourcePrimKey, orderByComparator, false);
1738    
1739                            return array;
1740                    }
1741                    catch (Exception e) {
1742                            throw processException(e);
1743                    }
1744                    finally {
1745                            closeSession(session);
1746                    }
1747            }
1748    
1749            protected JournalArticle getByResourcePrimKey_PrevAndNext(Session session,
1750                    JournalArticle journalArticle, long resourcePrimKey,
1751                    OrderByComparator orderByComparator, boolean previous) {
1752                    StringBundler query = null;
1753    
1754                    if (orderByComparator != null) {
1755                            query = new StringBundler(6 +
1756                                            (orderByComparator.getOrderByFields().length * 6));
1757                    }
1758                    else {
1759                            query = new StringBundler(3);
1760                    }
1761    
1762                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1763    
1764                    query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
1765    
1766                    if (orderByComparator != null) {
1767                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1768    
1769                            if (orderByConditionFields.length > 0) {
1770                                    query.append(WHERE_AND);
1771                            }
1772    
1773                            for (int i = 0; i < orderByConditionFields.length; i++) {
1774                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1775                                    query.append(orderByConditionFields[i]);
1776    
1777                                    if ((i + 1) < orderByConditionFields.length) {
1778                                            if (orderByComparator.isAscending() ^ previous) {
1779                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1780                                            }
1781                                            else {
1782                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1783                                            }
1784                                    }
1785                                    else {
1786                                            if (orderByComparator.isAscending() ^ previous) {
1787                                                    query.append(WHERE_GREATER_THAN);
1788                                            }
1789                                            else {
1790                                                    query.append(WHERE_LESSER_THAN);
1791                                            }
1792                                    }
1793                            }
1794    
1795                            query.append(ORDER_BY_CLAUSE);
1796    
1797                            String[] orderByFields = orderByComparator.getOrderByFields();
1798    
1799                            for (int i = 0; i < orderByFields.length; i++) {
1800                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1801                                    query.append(orderByFields[i]);
1802    
1803                                    if ((i + 1) < orderByFields.length) {
1804                                            if (orderByComparator.isAscending() ^ previous) {
1805                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1806                                            }
1807                                            else {
1808                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1809                                            }
1810                                    }
1811                                    else {
1812                                            if (orderByComparator.isAscending() ^ previous) {
1813                                                    query.append(ORDER_BY_ASC);
1814                                            }
1815                                            else {
1816                                                    query.append(ORDER_BY_DESC);
1817                                            }
1818                                    }
1819                            }
1820                    }
1821                    else {
1822                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1823                    }
1824    
1825                    String sql = query.toString();
1826    
1827                    Query q = session.createQuery(sql);
1828    
1829                    q.setFirstResult(0);
1830                    q.setMaxResults(2);
1831    
1832                    QueryPos qPos = QueryPos.getInstance(q);
1833    
1834                    qPos.add(resourcePrimKey);
1835    
1836                    if (orderByComparator != null) {
1837                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
1838    
1839                            for (Object value : values) {
1840                                    qPos.add(value);
1841                            }
1842                    }
1843    
1844                    List<JournalArticle> list = q.list();
1845    
1846                    if (list.size() == 2) {
1847                            return list.get(1);
1848                    }
1849                    else {
1850                            return null;
1851                    }
1852            }
1853    
1854            /**
1855             * Removes all the journal articles where resourcePrimKey = &#63; from the database.
1856             *
1857             * @param resourcePrimKey the resource prim key
1858             * @throws SystemException if a system exception occurred
1859             */
1860            public void removeByResourcePrimKey(long resourcePrimKey)
1861                    throws SystemException {
1862                    for (JournalArticle journalArticle : findByResourcePrimKey(
1863                                    resourcePrimKey, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1864                            remove(journalArticle);
1865                    }
1866            }
1867    
1868            /**
1869             * Returns the number of journal articles where resourcePrimKey = &#63;.
1870             *
1871             * @param resourcePrimKey the resource prim key
1872             * @return the number of matching journal articles
1873             * @throws SystemException if a system exception occurred
1874             */
1875            public int countByResourcePrimKey(long resourcePrimKey)
1876                    throws SystemException {
1877                    FinderPath finderPath = FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY;
1878    
1879                    Object[] finderArgs = new Object[] { resourcePrimKey };
1880    
1881                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1882                                    this);
1883    
1884                    if (count == null) {
1885                            StringBundler query = new StringBundler(2);
1886    
1887                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
1888    
1889                            query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
1890    
1891                            String sql = query.toString();
1892    
1893                            Session session = null;
1894    
1895                            try {
1896                                    session = openSession();
1897    
1898                                    Query q = session.createQuery(sql);
1899    
1900                                    QueryPos qPos = QueryPos.getInstance(q);
1901    
1902                                    qPos.add(resourcePrimKey);
1903    
1904                                    count = (Long)q.uniqueResult();
1905    
1906                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1907                            }
1908                            catch (Exception e) {
1909                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1910    
1911                                    throw processException(e);
1912                            }
1913                            finally {
1914                                    closeSession(session);
1915                            }
1916                    }
1917    
1918                    return count.intValue();
1919            }
1920    
1921            private static final String _FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2 =
1922                    "journalArticle.resourcePrimKey = ?";
1923            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1924                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
1925                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1926                            "findByGroupId",
1927                            new String[] {
1928                                    Long.class.getName(),
1929                                    
1930                            Integer.class.getName(), Integer.class.getName(),
1931                                    OrderByComparator.class.getName()
1932                            });
1933            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1934                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1935                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
1936                            JournalArticleImpl.class,
1937                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1938                            new String[] { Long.class.getName() },
1939                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
1940                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
1941                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
1942            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1943                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
1944                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1945                            new String[] { Long.class.getName() });
1946    
1947            /**
1948             * Returns all the journal articles where groupId = &#63;.
1949             *
1950             * @param groupId the group ID
1951             * @return the matching journal articles
1952             * @throws SystemException if a system exception occurred
1953             */
1954            public List<JournalArticle> findByGroupId(long groupId)
1955                    throws SystemException {
1956                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1957            }
1958    
1959            /**
1960             * Returns a range of all the journal articles where groupId = &#63;.
1961             *
1962             * <p>
1963             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1964             * </p>
1965             *
1966             * @param groupId the group ID
1967             * @param start the lower bound of the range of journal articles
1968             * @param end the upper bound of the range of journal articles (not inclusive)
1969             * @return the range of matching journal articles
1970             * @throws SystemException if a system exception occurred
1971             */
1972            public List<JournalArticle> findByGroupId(long groupId, int start, int end)
1973                    throws SystemException {
1974                    return findByGroupId(groupId, start, end, null);
1975            }
1976    
1977            /**
1978             * Returns an ordered range of all the journal articles where groupId = &#63;.
1979             *
1980             * <p>
1981             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1982             * </p>
1983             *
1984             * @param groupId the group ID
1985             * @param start the lower bound of the range of journal articles
1986             * @param end the upper bound of the range of journal articles (not inclusive)
1987             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1988             * @return the ordered range of matching journal articles
1989             * @throws SystemException if a system exception occurred
1990             */
1991            public List<JournalArticle> findByGroupId(long groupId, int start, int end,
1992                    OrderByComparator orderByComparator) throws SystemException {
1993                    boolean pagination = true;
1994                    FinderPath finderPath = null;
1995                    Object[] finderArgs = null;
1996    
1997                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1998                                    (orderByComparator == null)) {
1999                            pagination = false;
2000                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
2001                            finderArgs = new Object[] { groupId };
2002                    }
2003                    else {
2004                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
2005                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
2006                    }
2007    
2008                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
2009                                    finderArgs, this);
2010    
2011                    if ((list != null) && !list.isEmpty()) {
2012                            for (JournalArticle journalArticle : list) {
2013                                    if ((groupId != journalArticle.getGroupId())) {
2014                                            list = null;
2015    
2016                                            break;
2017                                    }
2018                            }
2019                    }
2020    
2021                    if (list == null) {
2022                            StringBundler query = null;
2023    
2024                            if (orderByComparator != null) {
2025                                    query = new StringBundler(3 +
2026                                                    (orderByComparator.getOrderByFields().length * 3));
2027                            }
2028                            else {
2029                                    query = new StringBundler(3);
2030                            }
2031    
2032                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2033    
2034                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2035    
2036                            if (orderByComparator != null) {
2037                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2038                                            orderByComparator);
2039                            }
2040                            else
2041                             if (pagination) {
2042                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2043                            }
2044    
2045                            String sql = query.toString();
2046    
2047                            Session session = null;
2048    
2049                            try {
2050                                    session = openSession();
2051    
2052                                    Query q = session.createQuery(sql);
2053    
2054                                    QueryPos qPos = QueryPos.getInstance(q);
2055    
2056                                    qPos.add(groupId);
2057    
2058                                    if (!pagination) {
2059                                            list = (List<JournalArticle>)QueryUtil.list(q,
2060                                                            getDialect(), start, end, false);
2061    
2062                                            Collections.sort(list);
2063    
2064                                            list = new UnmodifiableList<JournalArticle>(list);
2065                                    }
2066                                    else {
2067                                            list = (List<JournalArticle>)QueryUtil.list(q,
2068                                                            getDialect(), start, end);
2069                                    }
2070    
2071                                    cacheResult(list);
2072    
2073                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2074                            }
2075                            catch (Exception e) {
2076                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2077    
2078                                    throw processException(e);
2079                            }
2080                            finally {
2081                                    closeSession(session);
2082                            }
2083                    }
2084    
2085                    return list;
2086            }
2087    
2088            /**
2089             * Returns the first journal article in the ordered set where groupId = &#63;.
2090             *
2091             * @param groupId the group ID
2092             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2093             * @return the first matching journal article
2094             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2095             * @throws SystemException if a system exception occurred
2096             */
2097            public JournalArticle findByGroupId_First(long groupId,
2098                    OrderByComparator orderByComparator)
2099                    throws NoSuchArticleException, SystemException {
2100                    JournalArticle journalArticle = fetchByGroupId_First(groupId,
2101                                    orderByComparator);
2102    
2103                    if (journalArticle != null) {
2104                            return journalArticle;
2105                    }
2106    
2107                    StringBundler msg = new StringBundler(4);
2108    
2109                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2110    
2111                    msg.append("groupId=");
2112                    msg.append(groupId);
2113    
2114                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2115    
2116                    throw new NoSuchArticleException(msg.toString());
2117            }
2118    
2119            /**
2120             * Returns the first journal article in the ordered set where groupId = &#63;.
2121             *
2122             * @param groupId the group ID
2123             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2124             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
2125             * @throws SystemException if a system exception occurred
2126             */
2127            public JournalArticle fetchByGroupId_First(long groupId,
2128                    OrderByComparator orderByComparator) throws SystemException {
2129                    List<JournalArticle> list = findByGroupId(groupId, 0, 1,
2130                                    orderByComparator);
2131    
2132                    if (!list.isEmpty()) {
2133                            return list.get(0);
2134                    }
2135    
2136                    return null;
2137            }
2138    
2139            /**
2140             * Returns the last journal article in the ordered set where groupId = &#63;.
2141             *
2142             * @param groupId the group ID
2143             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2144             * @return the last matching journal article
2145             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2146             * @throws SystemException if a system exception occurred
2147             */
2148            public JournalArticle findByGroupId_Last(long groupId,
2149                    OrderByComparator orderByComparator)
2150                    throws NoSuchArticleException, SystemException {
2151                    JournalArticle journalArticle = fetchByGroupId_Last(groupId,
2152                                    orderByComparator);
2153    
2154                    if (journalArticle != null) {
2155                            return journalArticle;
2156                    }
2157    
2158                    StringBundler msg = new StringBundler(4);
2159    
2160                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2161    
2162                    msg.append("groupId=");
2163                    msg.append(groupId);
2164    
2165                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2166    
2167                    throw new NoSuchArticleException(msg.toString());
2168            }
2169    
2170            /**
2171             * Returns the last journal article in the ordered set where groupId = &#63;.
2172             *
2173             * @param groupId the group ID
2174             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2175             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
2176             * @throws SystemException if a system exception occurred
2177             */
2178            public JournalArticle fetchByGroupId_Last(long groupId,
2179                    OrderByComparator orderByComparator) throws SystemException {
2180                    int count = countByGroupId(groupId);
2181    
2182                    List<JournalArticle> list = findByGroupId(groupId, count - 1, count,
2183                                    orderByComparator);
2184    
2185                    if (!list.isEmpty()) {
2186                            return list.get(0);
2187                    }
2188    
2189                    return null;
2190            }
2191    
2192            /**
2193             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63;.
2194             *
2195             * @param id the primary key of the current journal article
2196             * @param groupId the group ID
2197             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2198             * @return the previous, current, and next journal article
2199             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
2200             * @throws SystemException if a system exception occurred
2201             */
2202            public JournalArticle[] findByGroupId_PrevAndNext(long id, long groupId,
2203                    OrderByComparator orderByComparator)
2204                    throws NoSuchArticleException, SystemException {
2205                    JournalArticle journalArticle = findByPrimaryKey(id);
2206    
2207                    Session session = null;
2208    
2209                    try {
2210                            session = openSession();
2211    
2212                            JournalArticle[] array = new JournalArticleImpl[3];
2213    
2214                            array[0] = getByGroupId_PrevAndNext(session, journalArticle,
2215                                            groupId, orderByComparator, true);
2216    
2217                            array[1] = journalArticle;
2218    
2219                            array[2] = getByGroupId_PrevAndNext(session, journalArticle,
2220                                            groupId, orderByComparator, false);
2221    
2222                            return array;
2223                    }
2224                    catch (Exception e) {
2225                            throw processException(e);
2226                    }
2227                    finally {
2228                            closeSession(session);
2229                    }
2230            }
2231    
2232            protected JournalArticle getByGroupId_PrevAndNext(Session session,
2233                    JournalArticle journalArticle, long groupId,
2234                    OrderByComparator orderByComparator, boolean previous) {
2235                    StringBundler query = null;
2236    
2237                    if (orderByComparator != null) {
2238                            query = new StringBundler(6 +
2239                                            (orderByComparator.getOrderByFields().length * 6));
2240                    }
2241                    else {
2242                            query = new StringBundler(3);
2243                    }
2244    
2245                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2246    
2247                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2248    
2249                    if (orderByComparator != null) {
2250                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2251    
2252                            if (orderByConditionFields.length > 0) {
2253                                    query.append(WHERE_AND);
2254                            }
2255    
2256                            for (int i = 0; i < orderByConditionFields.length; i++) {
2257                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2258                                    query.append(orderByConditionFields[i]);
2259    
2260                                    if ((i + 1) < orderByConditionFields.length) {
2261                                            if (orderByComparator.isAscending() ^ previous) {
2262                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2263                                            }
2264                                            else {
2265                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2266                                            }
2267                                    }
2268                                    else {
2269                                            if (orderByComparator.isAscending() ^ previous) {
2270                                                    query.append(WHERE_GREATER_THAN);
2271                                            }
2272                                            else {
2273                                                    query.append(WHERE_LESSER_THAN);
2274                                            }
2275                                    }
2276                            }
2277    
2278                            query.append(ORDER_BY_CLAUSE);
2279    
2280                            String[] orderByFields = orderByComparator.getOrderByFields();
2281    
2282                            for (int i = 0; i < orderByFields.length; i++) {
2283                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2284                                    query.append(orderByFields[i]);
2285    
2286                                    if ((i + 1) < orderByFields.length) {
2287                                            if (orderByComparator.isAscending() ^ previous) {
2288                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2289                                            }
2290                                            else {
2291                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2292                                            }
2293                                    }
2294                                    else {
2295                                            if (orderByComparator.isAscending() ^ previous) {
2296                                                    query.append(ORDER_BY_ASC);
2297                                            }
2298                                            else {
2299                                                    query.append(ORDER_BY_DESC);
2300                                            }
2301                                    }
2302                            }
2303                    }
2304                    else {
2305                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2306                    }
2307    
2308                    String sql = query.toString();
2309    
2310                    Query q = session.createQuery(sql);
2311    
2312                    q.setFirstResult(0);
2313                    q.setMaxResults(2);
2314    
2315                    QueryPos qPos = QueryPos.getInstance(q);
2316    
2317                    qPos.add(groupId);
2318    
2319                    if (orderByComparator != null) {
2320                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
2321    
2322                            for (Object value : values) {
2323                                    qPos.add(value);
2324                            }
2325                    }
2326    
2327                    List<JournalArticle> list = q.list();
2328    
2329                    if (list.size() == 2) {
2330                            return list.get(1);
2331                    }
2332                    else {
2333                            return null;
2334                    }
2335            }
2336    
2337            /**
2338             * Returns all the journal articles that the user has permission to view where groupId = &#63;.
2339             *
2340             * @param groupId the group ID
2341             * @return the matching journal articles that the user has permission to view
2342             * @throws SystemException if a system exception occurred
2343             */
2344            public List<JournalArticle> filterFindByGroupId(long groupId)
2345                    throws SystemException {
2346                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
2347                            QueryUtil.ALL_POS, null);
2348            }
2349    
2350            /**
2351             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63;.
2352             *
2353             * <p>
2354             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2355             * </p>
2356             *
2357             * @param groupId the group ID
2358             * @param start the lower bound of the range of journal articles
2359             * @param end the upper bound of the range of journal articles (not inclusive)
2360             * @return the range of matching journal articles that the user has permission to view
2361             * @throws SystemException if a system exception occurred
2362             */
2363            public List<JournalArticle> filterFindByGroupId(long groupId, int start,
2364                    int end) throws SystemException {
2365                    return filterFindByGroupId(groupId, start, end, null);
2366            }
2367    
2368            /**
2369             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63;.
2370             *
2371             * <p>
2372             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2373             * </p>
2374             *
2375             * @param groupId the group ID
2376             * @param start the lower bound of the range of journal articles
2377             * @param end the upper bound of the range of journal articles (not inclusive)
2378             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2379             * @return the ordered range of matching journal articles that the user has permission to view
2380             * @throws SystemException if a system exception occurred
2381             */
2382            public List<JournalArticle> filterFindByGroupId(long groupId, int start,
2383                    int end, OrderByComparator orderByComparator) throws SystemException {
2384                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2385                            return findByGroupId(groupId, start, end, orderByComparator);
2386                    }
2387    
2388                    StringBundler query = null;
2389    
2390                    if (orderByComparator != null) {
2391                            query = new StringBundler(3 +
2392                                            (orderByComparator.getOrderByFields().length * 3));
2393                    }
2394                    else {
2395                            query = new StringBundler(3);
2396                    }
2397    
2398                    if (getDB().isSupportsInlineDistinct()) {
2399                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
2400                    }
2401                    else {
2402                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
2403                    }
2404    
2405                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2406    
2407                    if (!getDB().isSupportsInlineDistinct()) {
2408                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
2409                    }
2410    
2411                    if (orderByComparator != null) {
2412                            if (getDB().isSupportsInlineDistinct()) {
2413                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2414                                            orderByComparator);
2415                            }
2416                            else {
2417                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2418                                            orderByComparator);
2419                            }
2420                    }
2421                    else {
2422                            if (getDB().isSupportsInlineDistinct()) {
2423                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2424                            }
2425                            else {
2426                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
2427                            }
2428                    }
2429    
2430                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2431                                    JournalArticle.class.getName(),
2432                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2433    
2434                    Session session = null;
2435    
2436                    try {
2437                            session = openSession();
2438    
2439                            SQLQuery q = session.createSQLQuery(sql);
2440    
2441                            if (getDB().isSupportsInlineDistinct()) {
2442                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
2443                            }
2444                            else {
2445                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
2446                            }
2447    
2448                            QueryPos qPos = QueryPos.getInstance(q);
2449    
2450                            qPos.add(groupId);
2451    
2452                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
2453                                    end);
2454                    }
2455                    catch (Exception e) {
2456                            throw processException(e);
2457                    }
2458                    finally {
2459                            closeSession(session);
2460                    }
2461            }
2462    
2463            /**
2464             * 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;.
2465             *
2466             * @param id the primary key of the current journal article
2467             * @param groupId the group ID
2468             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2469             * @return the previous, current, and next journal article
2470             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
2471             * @throws SystemException if a system exception occurred
2472             */
2473            public JournalArticle[] filterFindByGroupId_PrevAndNext(long id,
2474                    long groupId, OrderByComparator orderByComparator)
2475                    throws NoSuchArticleException, SystemException {
2476                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2477                            return findByGroupId_PrevAndNext(id, groupId, orderByComparator);
2478                    }
2479    
2480                    JournalArticle journalArticle = findByPrimaryKey(id);
2481    
2482                    Session session = null;
2483    
2484                    try {
2485                            session = openSession();
2486    
2487                            JournalArticle[] array = new JournalArticleImpl[3];
2488    
2489                            array[0] = filterGetByGroupId_PrevAndNext(session, journalArticle,
2490                                            groupId, orderByComparator, true);
2491    
2492                            array[1] = journalArticle;
2493    
2494                            array[2] = filterGetByGroupId_PrevAndNext(session, journalArticle,
2495                                            groupId, orderByComparator, false);
2496    
2497                            return array;
2498                    }
2499                    catch (Exception e) {
2500                            throw processException(e);
2501                    }
2502                    finally {
2503                            closeSession(session);
2504                    }
2505            }
2506    
2507            protected JournalArticle filterGetByGroupId_PrevAndNext(Session session,
2508                    JournalArticle journalArticle, long groupId,
2509                    OrderByComparator orderByComparator, boolean previous) {
2510                    StringBundler query = null;
2511    
2512                    if (orderByComparator != null) {
2513                            query = new StringBundler(6 +
2514                                            (orderByComparator.getOrderByFields().length * 6));
2515                    }
2516                    else {
2517                            query = new StringBundler(3);
2518                    }
2519    
2520                    if (getDB().isSupportsInlineDistinct()) {
2521                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
2522                    }
2523                    else {
2524                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
2525                    }
2526    
2527                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2528    
2529                    if (!getDB().isSupportsInlineDistinct()) {
2530                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
2531                    }
2532    
2533                    if (orderByComparator != null) {
2534                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2535    
2536                            if (orderByConditionFields.length > 0) {
2537                                    query.append(WHERE_AND);
2538                            }
2539    
2540                            for (int i = 0; i < orderByConditionFields.length; i++) {
2541                                    if (getDB().isSupportsInlineDistinct()) {
2542                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2543                                    }
2544                                    else {
2545                                            query.append(_ORDER_BY_ENTITY_TABLE);
2546                                    }
2547    
2548                                    query.append(orderByConditionFields[i]);
2549    
2550                                    if ((i + 1) < orderByConditionFields.length) {
2551                                            if (orderByComparator.isAscending() ^ previous) {
2552                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2553                                            }
2554                                            else {
2555                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2556                                            }
2557                                    }
2558                                    else {
2559                                            if (orderByComparator.isAscending() ^ previous) {
2560                                                    query.append(WHERE_GREATER_THAN);
2561                                            }
2562                                            else {
2563                                                    query.append(WHERE_LESSER_THAN);
2564                                            }
2565                                    }
2566                            }
2567    
2568                            query.append(ORDER_BY_CLAUSE);
2569    
2570                            String[] orderByFields = orderByComparator.getOrderByFields();
2571    
2572                            for (int i = 0; i < orderByFields.length; i++) {
2573                                    if (getDB().isSupportsInlineDistinct()) {
2574                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2575                                    }
2576                                    else {
2577                                            query.append(_ORDER_BY_ENTITY_TABLE);
2578                                    }
2579    
2580                                    query.append(orderByFields[i]);
2581    
2582                                    if ((i + 1) < orderByFields.length) {
2583                                            if (orderByComparator.isAscending() ^ previous) {
2584                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2585                                            }
2586                                            else {
2587                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2588                                            }
2589                                    }
2590                                    else {
2591                                            if (orderByComparator.isAscending() ^ previous) {
2592                                                    query.append(ORDER_BY_ASC);
2593                                            }
2594                                            else {
2595                                                    query.append(ORDER_BY_DESC);
2596                                            }
2597                                    }
2598                            }
2599                    }
2600                    else {
2601                            if (getDB().isSupportsInlineDistinct()) {
2602                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2603                            }
2604                            else {
2605                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
2606                            }
2607                    }
2608    
2609                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2610                                    JournalArticle.class.getName(),
2611                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2612    
2613                    SQLQuery q = session.createSQLQuery(sql);
2614    
2615                    q.setFirstResult(0);
2616                    q.setMaxResults(2);
2617    
2618                    if (getDB().isSupportsInlineDistinct()) {
2619                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
2620                    }
2621                    else {
2622                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
2623                    }
2624    
2625                    QueryPos qPos = QueryPos.getInstance(q);
2626    
2627                    qPos.add(groupId);
2628    
2629                    if (orderByComparator != null) {
2630                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
2631    
2632                            for (Object value : values) {
2633                                    qPos.add(value);
2634                            }
2635                    }
2636    
2637                    List<JournalArticle> list = q.list();
2638    
2639                    if (list.size() == 2) {
2640                            return list.get(1);
2641                    }
2642                    else {
2643                            return null;
2644                    }
2645            }
2646    
2647            /**
2648             * Removes all the journal articles where groupId = &#63; from the database.
2649             *
2650             * @param groupId the group ID
2651             * @throws SystemException if a system exception occurred
2652             */
2653            public void removeByGroupId(long groupId) throws SystemException {
2654                    for (JournalArticle journalArticle : findByGroupId(groupId,
2655                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2656                            remove(journalArticle);
2657                    }
2658            }
2659    
2660            /**
2661             * Returns the number of journal articles where groupId = &#63;.
2662             *
2663             * @param groupId the group ID
2664             * @return the number of matching journal articles
2665             * @throws SystemException if a system exception occurred
2666             */
2667            public int countByGroupId(long groupId) throws SystemException {
2668                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2669    
2670                    Object[] finderArgs = new Object[] { groupId };
2671    
2672                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2673                                    this);
2674    
2675                    if (count == null) {
2676                            StringBundler query = new StringBundler(2);
2677    
2678                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
2679    
2680                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2681    
2682                            String sql = query.toString();
2683    
2684                            Session session = null;
2685    
2686                            try {
2687                                    session = openSession();
2688    
2689                                    Query q = session.createQuery(sql);
2690    
2691                                    QueryPos qPos = QueryPos.getInstance(q);
2692    
2693                                    qPos.add(groupId);
2694    
2695                                    count = (Long)q.uniqueResult();
2696    
2697                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2698                            }
2699                            catch (Exception e) {
2700                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2701    
2702                                    throw processException(e);
2703                            }
2704                            finally {
2705                                    closeSession(session);
2706                            }
2707                    }
2708    
2709                    return count.intValue();
2710            }
2711    
2712            /**
2713             * Returns the number of journal articles that the user has permission to view where groupId = &#63;.
2714             *
2715             * @param groupId the group ID
2716             * @return the number of matching journal articles that the user has permission to view
2717             * @throws SystemException if a system exception occurred
2718             */
2719            public int filterCountByGroupId(long groupId) throws SystemException {
2720                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2721                            return countByGroupId(groupId);
2722                    }
2723    
2724                    StringBundler query = new StringBundler(2);
2725    
2726                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
2727    
2728                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2729    
2730                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2731                                    JournalArticle.class.getName(),
2732                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2733    
2734                    Session session = null;
2735    
2736                    try {
2737                            session = openSession();
2738    
2739                            SQLQuery q = session.createSQLQuery(sql);
2740    
2741                            q.addScalar(COUNT_COLUMN_NAME,
2742                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2743    
2744                            QueryPos qPos = QueryPos.getInstance(q);
2745    
2746                            qPos.add(groupId);
2747    
2748                            Long count = (Long)q.uniqueResult();
2749    
2750                            return count.intValue();
2751                    }
2752                    catch (Exception e) {
2753                            throw processException(e);
2754                    }
2755                    finally {
2756                            closeSession(session);
2757                    }
2758            }
2759    
2760            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "journalArticle.groupId = ?";
2761            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2762                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
2763                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
2764                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2765                            "findByCompanyId",
2766                            new String[] {
2767                                    Long.class.getName(),
2768                                    
2769                            Integer.class.getName(), Integer.class.getName(),
2770                                    OrderByComparator.class.getName()
2771                            });
2772            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2773                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
2774                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
2775                            JournalArticleImpl.class,
2776                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2777                            new String[] { Long.class.getName() },
2778                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
2779                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
2780                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
2781            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
2782                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
2783                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2784                            new String[] { Long.class.getName() });
2785    
2786            /**
2787             * Returns all the journal articles where companyId = &#63;.
2788             *
2789             * @param companyId the company ID
2790             * @return the matching journal articles
2791             * @throws SystemException if a system exception occurred
2792             */
2793            public List<JournalArticle> findByCompanyId(long companyId)
2794                    throws SystemException {
2795                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2796                            null);
2797            }
2798    
2799            /**
2800             * Returns a range of all the journal articles where companyId = &#63;.
2801             *
2802             * <p>
2803             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2804             * </p>
2805             *
2806             * @param companyId the company ID
2807             * @param start the lower bound of the range of journal articles
2808             * @param end the upper bound of the range of journal articles (not inclusive)
2809             * @return the range of matching journal articles
2810             * @throws SystemException if a system exception occurred
2811             */
2812            public List<JournalArticle> findByCompanyId(long companyId, int start,
2813                    int end) throws SystemException {
2814                    return findByCompanyId(companyId, start, end, null);
2815            }
2816    
2817            /**
2818             * Returns an ordered range of all the journal articles where companyId = &#63;.
2819             *
2820             * <p>
2821             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2822             * </p>
2823             *
2824             * @param companyId the company ID
2825             * @param start the lower bound of the range of journal articles
2826             * @param end the upper bound of the range of journal articles (not inclusive)
2827             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2828             * @return the ordered range of matching journal articles
2829             * @throws SystemException if a system exception occurred
2830             */
2831            public List<JournalArticle> findByCompanyId(long companyId, int start,
2832                    int end, OrderByComparator orderByComparator) throws SystemException {
2833                    boolean pagination = true;
2834                    FinderPath finderPath = null;
2835                    Object[] finderArgs = null;
2836    
2837                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2838                                    (orderByComparator == null)) {
2839                            pagination = false;
2840                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2841                            finderArgs = new Object[] { companyId };
2842                    }
2843                    else {
2844                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2845                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2846                    }
2847    
2848                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
2849                                    finderArgs, this);
2850    
2851                    if ((list != null) && !list.isEmpty()) {
2852                            for (JournalArticle journalArticle : list) {
2853                                    if ((companyId != journalArticle.getCompanyId())) {
2854                                            list = null;
2855    
2856                                            break;
2857                                    }
2858                            }
2859                    }
2860    
2861                    if (list == null) {
2862                            StringBundler query = null;
2863    
2864                            if (orderByComparator != null) {
2865                                    query = new StringBundler(3 +
2866                                                    (orderByComparator.getOrderByFields().length * 3));
2867                            }
2868                            else {
2869                                    query = new StringBundler(3);
2870                            }
2871    
2872                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2873    
2874                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2875    
2876                            if (orderByComparator != null) {
2877                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2878                                            orderByComparator);
2879                            }
2880                            else
2881                             if (pagination) {
2882                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2883                            }
2884    
2885                            String sql = query.toString();
2886    
2887                            Session session = null;
2888    
2889                            try {
2890                                    session = openSession();
2891    
2892                                    Query q = session.createQuery(sql);
2893    
2894                                    QueryPos qPos = QueryPos.getInstance(q);
2895    
2896                                    qPos.add(companyId);
2897    
2898                                    if (!pagination) {
2899                                            list = (List<JournalArticle>)QueryUtil.list(q,
2900                                                            getDialect(), start, end, false);
2901    
2902                                            Collections.sort(list);
2903    
2904                                            list = new UnmodifiableList<JournalArticle>(list);
2905                                    }
2906                                    else {
2907                                            list = (List<JournalArticle>)QueryUtil.list(q,
2908                                                            getDialect(), start, end);
2909                                    }
2910    
2911                                    cacheResult(list);
2912    
2913                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2914                            }
2915                            catch (Exception e) {
2916                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2917    
2918                                    throw processException(e);
2919                            }
2920                            finally {
2921                                    closeSession(session);
2922                            }
2923                    }
2924    
2925                    return list;
2926            }
2927    
2928            /**
2929             * Returns the first journal article in the ordered set where companyId = &#63;.
2930             *
2931             * @param companyId the company ID
2932             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2933             * @return the first matching journal article
2934             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2935             * @throws SystemException if a system exception occurred
2936             */
2937            public JournalArticle findByCompanyId_First(long companyId,
2938                    OrderByComparator orderByComparator)
2939                    throws NoSuchArticleException, SystemException {
2940                    JournalArticle journalArticle = fetchByCompanyId_First(companyId,
2941                                    orderByComparator);
2942    
2943                    if (journalArticle != null) {
2944                            return journalArticle;
2945                    }
2946    
2947                    StringBundler msg = new StringBundler(4);
2948    
2949                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2950    
2951                    msg.append("companyId=");
2952                    msg.append(companyId);
2953    
2954                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2955    
2956                    throw new NoSuchArticleException(msg.toString());
2957            }
2958    
2959            /**
2960             * Returns the first journal article in the ordered set where companyId = &#63;.
2961             *
2962             * @param companyId the company ID
2963             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2964             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
2965             * @throws SystemException if a system exception occurred
2966             */
2967            public JournalArticle fetchByCompanyId_First(long companyId,
2968                    OrderByComparator orderByComparator) throws SystemException {
2969                    List<JournalArticle> list = findByCompanyId(companyId, 0, 1,
2970                                    orderByComparator);
2971    
2972                    if (!list.isEmpty()) {
2973                            return list.get(0);
2974                    }
2975    
2976                    return null;
2977            }
2978    
2979            /**
2980             * Returns the last journal article in the ordered set where companyId = &#63;.
2981             *
2982             * @param companyId the company ID
2983             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2984             * @return the last matching journal article
2985             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2986             * @throws SystemException if a system exception occurred
2987             */
2988            public JournalArticle findByCompanyId_Last(long companyId,
2989                    OrderByComparator orderByComparator)
2990                    throws NoSuchArticleException, SystemException {
2991                    JournalArticle journalArticle = fetchByCompanyId_Last(companyId,
2992                                    orderByComparator);
2993    
2994                    if (journalArticle != null) {
2995                            return journalArticle;
2996                    }
2997    
2998                    StringBundler msg = new StringBundler(4);
2999    
3000                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3001    
3002                    msg.append("companyId=");
3003                    msg.append(companyId);
3004    
3005                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3006    
3007                    throw new NoSuchArticleException(msg.toString());
3008            }
3009    
3010            /**
3011             * Returns the last journal article in the ordered set where companyId = &#63;.
3012             *
3013             * @param companyId the company ID
3014             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3015             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
3016             * @throws SystemException if a system exception occurred
3017             */
3018            public JournalArticle fetchByCompanyId_Last(long companyId,
3019                    OrderByComparator orderByComparator) throws SystemException {
3020                    int count = countByCompanyId(companyId);
3021    
3022                    List<JournalArticle> list = findByCompanyId(companyId, count - 1,
3023                                    count, orderByComparator);
3024    
3025                    if (!list.isEmpty()) {
3026                            return list.get(0);
3027                    }
3028    
3029                    return null;
3030            }
3031    
3032            /**
3033             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63;.
3034             *
3035             * @param id the primary key of the current journal article
3036             * @param companyId the company ID
3037             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3038             * @return the previous, current, and next journal article
3039             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
3040             * @throws SystemException if a system exception occurred
3041             */
3042            public JournalArticle[] findByCompanyId_PrevAndNext(long id,
3043                    long companyId, OrderByComparator orderByComparator)
3044                    throws NoSuchArticleException, SystemException {
3045                    JournalArticle journalArticle = findByPrimaryKey(id);
3046    
3047                    Session session = null;
3048    
3049                    try {
3050                            session = openSession();
3051    
3052                            JournalArticle[] array = new JournalArticleImpl[3];
3053    
3054                            array[0] = getByCompanyId_PrevAndNext(session, journalArticle,
3055                                            companyId, orderByComparator, true);
3056    
3057                            array[1] = journalArticle;
3058    
3059                            array[2] = getByCompanyId_PrevAndNext(session, journalArticle,
3060                                            companyId, orderByComparator, false);
3061    
3062                            return array;
3063                    }
3064                    catch (Exception e) {
3065                            throw processException(e);
3066                    }
3067                    finally {
3068                            closeSession(session);
3069                    }
3070            }
3071    
3072            protected JournalArticle getByCompanyId_PrevAndNext(Session session,
3073                    JournalArticle journalArticle, long companyId,
3074                    OrderByComparator orderByComparator, boolean previous) {
3075                    StringBundler query = null;
3076    
3077                    if (orderByComparator != null) {
3078                            query = new StringBundler(6 +
3079                                            (orderByComparator.getOrderByFields().length * 6));
3080                    }
3081                    else {
3082                            query = new StringBundler(3);
3083                    }
3084    
3085                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3086    
3087                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3088    
3089                    if (orderByComparator != null) {
3090                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3091    
3092                            if (orderByConditionFields.length > 0) {
3093                                    query.append(WHERE_AND);
3094                            }
3095    
3096                            for (int i = 0; i < orderByConditionFields.length; i++) {
3097                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3098                                    query.append(orderByConditionFields[i]);
3099    
3100                                    if ((i + 1) < orderByConditionFields.length) {
3101                                            if (orderByComparator.isAscending() ^ previous) {
3102                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3103                                            }
3104                                            else {
3105                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3106                                            }
3107                                    }
3108                                    else {
3109                                            if (orderByComparator.isAscending() ^ previous) {
3110                                                    query.append(WHERE_GREATER_THAN);
3111                                            }
3112                                            else {
3113                                                    query.append(WHERE_LESSER_THAN);
3114                                            }
3115                                    }
3116                            }
3117    
3118                            query.append(ORDER_BY_CLAUSE);
3119    
3120                            String[] orderByFields = orderByComparator.getOrderByFields();
3121    
3122                            for (int i = 0; i < orderByFields.length; i++) {
3123                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3124                                    query.append(orderByFields[i]);
3125    
3126                                    if ((i + 1) < orderByFields.length) {
3127                                            if (orderByComparator.isAscending() ^ previous) {
3128                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3129                                            }
3130                                            else {
3131                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3132                                            }
3133                                    }
3134                                    else {
3135                                            if (orderByComparator.isAscending() ^ previous) {
3136                                                    query.append(ORDER_BY_ASC);
3137                                            }
3138                                            else {
3139                                                    query.append(ORDER_BY_DESC);
3140                                            }
3141                                    }
3142                            }
3143                    }
3144                    else {
3145                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3146                    }
3147    
3148                    String sql = query.toString();
3149    
3150                    Query q = session.createQuery(sql);
3151    
3152                    q.setFirstResult(0);
3153                    q.setMaxResults(2);
3154    
3155                    QueryPos qPos = QueryPos.getInstance(q);
3156    
3157                    qPos.add(companyId);
3158    
3159                    if (orderByComparator != null) {
3160                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
3161    
3162                            for (Object value : values) {
3163                                    qPos.add(value);
3164                            }
3165                    }
3166    
3167                    List<JournalArticle> list = q.list();
3168    
3169                    if (list.size() == 2) {
3170                            return list.get(1);
3171                    }
3172                    else {
3173                            return null;
3174                    }
3175            }
3176    
3177            /**
3178             * Removes all the journal articles where companyId = &#63; from the database.
3179             *
3180             * @param companyId the company ID
3181             * @throws SystemException if a system exception occurred
3182             */
3183            public void removeByCompanyId(long companyId) throws SystemException {
3184                    for (JournalArticle journalArticle : findByCompanyId(companyId,
3185                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3186                            remove(journalArticle);
3187                    }
3188            }
3189    
3190            /**
3191             * Returns the number of journal articles where companyId = &#63;.
3192             *
3193             * @param companyId the company ID
3194             * @return the number of matching journal articles
3195             * @throws SystemException if a system exception occurred
3196             */
3197            public int countByCompanyId(long companyId) throws SystemException {
3198                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
3199    
3200                    Object[] finderArgs = new Object[] { companyId };
3201    
3202                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3203                                    this);
3204    
3205                    if (count == null) {
3206                            StringBundler query = new StringBundler(2);
3207    
3208                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
3209    
3210                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3211    
3212                            String sql = query.toString();
3213    
3214                            Session session = null;
3215    
3216                            try {
3217                                    session = openSession();
3218    
3219                                    Query q = session.createQuery(sql);
3220    
3221                                    QueryPos qPos = QueryPos.getInstance(q);
3222    
3223                                    qPos.add(companyId);
3224    
3225                                    count = (Long)q.uniqueResult();
3226    
3227                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3228                            }
3229                            catch (Exception e) {
3230                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3231    
3232                                    throw processException(e);
3233                            }
3234                            finally {
3235                                    closeSession(session);
3236                            }
3237                    }
3238    
3239                    return count.intValue();
3240            }
3241    
3242            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "journalArticle.companyId = ?";
3243            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID =
3244                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3245                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
3246                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
3247                            "findByStructureId",
3248                            new String[] {
3249                                    String.class.getName(),
3250                                    
3251                            Integer.class.getName(), Integer.class.getName(),
3252                                    OrderByComparator.class.getName()
3253                            });
3254            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID =
3255                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3256                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
3257                            JournalArticleImpl.class,
3258                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByStructureId",
3259                            new String[] { String.class.getName() },
3260                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK |
3261                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
3262                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
3263            public static final FinderPath FINDER_PATH_COUNT_BY_STRUCTUREID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3264                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
3265                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByStructureId",
3266                            new String[] { String.class.getName() });
3267    
3268            /**
3269             * Returns all the journal articles where structureId = &#63;.
3270             *
3271             * @param structureId the structure ID
3272             * @return the matching journal articles
3273             * @throws SystemException if a system exception occurred
3274             */
3275            public List<JournalArticle> findByStructureId(String structureId)
3276                    throws SystemException {
3277                    return findByStructureId(structureId, QueryUtil.ALL_POS,
3278                            QueryUtil.ALL_POS, null);
3279            }
3280    
3281            /**
3282             * Returns a range of all the journal articles where structureId = &#63;.
3283             *
3284             * <p>
3285             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3286             * </p>
3287             *
3288             * @param structureId the structure ID
3289             * @param start the lower bound of the range of journal articles
3290             * @param end the upper bound of the range of journal articles (not inclusive)
3291             * @return the range of matching journal articles
3292             * @throws SystemException if a system exception occurred
3293             */
3294            public List<JournalArticle> findByStructureId(String structureId,
3295                    int start, int end) throws SystemException {
3296                    return findByStructureId(structureId, start, end, null);
3297            }
3298    
3299            /**
3300             * Returns an ordered range of all the journal articles where structureId = &#63;.
3301             *
3302             * <p>
3303             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3304             * </p>
3305             *
3306             * @param structureId the structure ID
3307             * @param start the lower bound of the range of journal articles
3308             * @param end the upper bound of the range of journal articles (not inclusive)
3309             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3310             * @return the ordered range of matching journal articles
3311             * @throws SystemException if a system exception occurred
3312             */
3313            public List<JournalArticle> findByStructureId(String structureId,
3314                    int start, int end, OrderByComparator orderByComparator)
3315                    throws SystemException {
3316                    boolean pagination = true;
3317                    FinderPath finderPath = null;
3318                    Object[] finderArgs = null;
3319    
3320                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3321                                    (orderByComparator == null)) {
3322                            pagination = false;
3323                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID;
3324                            finderArgs = new Object[] { structureId };
3325                    }
3326                    else {
3327                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID;
3328                            finderArgs = new Object[] { structureId, start, end, orderByComparator };
3329                    }
3330    
3331                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
3332                                    finderArgs, this);
3333    
3334                    if ((list != null) && !list.isEmpty()) {
3335                            for (JournalArticle journalArticle : list) {
3336                                    if (!Validator.equals(structureId,
3337                                                            journalArticle.getStructureId())) {
3338                                            list = null;
3339    
3340                                            break;
3341                                    }
3342                            }
3343                    }
3344    
3345                    if (list == null) {
3346                            StringBundler query = null;
3347    
3348                            if (orderByComparator != null) {
3349                                    query = new StringBundler(3 +
3350                                                    (orderByComparator.getOrderByFields().length * 3));
3351                            }
3352                            else {
3353                                    query = new StringBundler(3);
3354                            }
3355    
3356                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3357    
3358                            boolean bindStructureId = false;
3359    
3360                            if (structureId == null) {
3361                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
3362                            }
3363                            else if (structureId.equals(StringPool.BLANK)) {
3364                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
3365                            }
3366                            else {
3367                                    bindStructureId = true;
3368    
3369                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
3370                            }
3371    
3372                            if (orderByComparator != null) {
3373                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3374                                            orderByComparator);
3375                            }
3376                            else
3377                             if (pagination) {
3378                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3379                            }
3380    
3381                            String sql = query.toString();
3382    
3383                            Session session = null;
3384    
3385                            try {
3386                                    session = openSession();
3387    
3388                                    Query q = session.createQuery(sql);
3389    
3390                                    QueryPos qPos = QueryPos.getInstance(q);
3391    
3392                                    if (bindStructureId) {
3393                                            qPos.add(structureId);
3394                                    }
3395    
3396                                    if (!pagination) {
3397                                            list = (List<JournalArticle>)QueryUtil.list(q,
3398                                                            getDialect(), start, end, false);
3399    
3400                                            Collections.sort(list);
3401    
3402                                            list = new UnmodifiableList<JournalArticle>(list);
3403                                    }
3404                                    else {
3405                                            list = (List<JournalArticle>)QueryUtil.list(q,
3406                                                            getDialect(), start, end);
3407                                    }
3408    
3409                                    cacheResult(list);
3410    
3411                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3412                            }
3413                            catch (Exception e) {
3414                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3415    
3416                                    throw processException(e);
3417                            }
3418                            finally {
3419                                    closeSession(session);
3420                            }
3421                    }
3422    
3423                    return list;
3424            }
3425    
3426            /**
3427             * Returns the first journal article in the ordered set where structureId = &#63;.
3428             *
3429             * @param structureId the structure ID
3430             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3431             * @return the first matching journal article
3432             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3433             * @throws SystemException if a system exception occurred
3434             */
3435            public JournalArticle findByStructureId_First(String structureId,
3436                    OrderByComparator orderByComparator)
3437                    throws NoSuchArticleException, SystemException {
3438                    JournalArticle journalArticle = fetchByStructureId_First(structureId,
3439                                    orderByComparator);
3440    
3441                    if (journalArticle != null) {
3442                            return journalArticle;
3443                    }
3444    
3445                    StringBundler msg = new StringBundler(4);
3446    
3447                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3448    
3449                    msg.append("structureId=");
3450                    msg.append(structureId);
3451    
3452                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3453    
3454                    throw new NoSuchArticleException(msg.toString());
3455            }
3456    
3457            /**
3458             * Returns the first journal article in the ordered set where structureId = &#63;.
3459             *
3460             * @param structureId the structure ID
3461             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3462             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
3463             * @throws SystemException if a system exception occurred
3464             */
3465            public JournalArticle fetchByStructureId_First(String structureId,
3466                    OrderByComparator orderByComparator) throws SystemException {
3467                    List<JournalArticle> list = findByStructureId(structureId, 0, 1,
3468                                    orderByComparator);
3469    
3470                    if (!list.isEmpty()) {
3471                            return list.get(0);
3472                    }
3473    
3474                    return null;
3475            }
3476    
3477            /**
3478             * Returns the last journal article in the ordered set where structureId = &#63;.
3479             *
3480             * @param structureId the structure ID
3481             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3482             * @return the last matching journal article
3483             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3484             * @throws SystemException if a system exception occurred
3485             */
3486            public JournalArticle findByStructureId_Last(String structureId,
3487                    OrderByComparator orderByComparator)
3488                    throws NoSuchArticleException, SystemException {
3489                    JournalArticle journalArticle = fetchByStructureId_Last(structureId,
3490                                    orderByComparator);
3491    
3492                    if (journalArticle != null) {
3493                            return journalArticle;
3494                    }
3495    
3496                    StringBundler msg = new StringBundler(4);
3497    
3498                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3499    
3500                    msg.append("structureId=");
3501                    msg.append(structureId);
3502    
3503                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3504    
3505                    throw new NoSuchArticleException(msg.toString());
3506            }
3507    
3508            /**
3509             * Returns the last journal article in the ordered set where structureId = &#63;.
3510             *
3511             * @param structureId the structure ID
3512             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3513             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
3514             * @throws SystemException if a system exception occurred
3515             */
3516            public JournalArticle fetchByStructureId_Last(String structureId,
3517                    OrderByComparator orderByComparator) throws SystemException {
3518                    int count = countByStructureId(structureId);
3519    
3520                    List<JournalArticle> list = findByStructureId(structureId, count - 1,
3521                                    count, orderByComparator);
3522    
3523                    if (!list.isEmpty()) {
3524                            return list.get(0);
3525                    }
3526    
3527                    return null;
3528            }
3529    
3530            /**
3531             * Returns the journal articles before and after the current journal article in the ordered set where structureId = &#63;.
3532             *
3533             * @param id the primary key of the current journal article
3534             * @param structureId the structure ID
3535             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3536             * @return the previous, current, and next journal article
3537             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
3538             * @throws SystemException if a system exception occurred
3539             */
3540            public JournalArticle[] findByStructureId_PrevAndNext(long id,
3541                    String structureId, OrderByComparator orderByComparator)
3542                    throws NoSuchArticleException, SystemException {
3543                    JournalArticle journalArticle = findByPrimaryKey(id);
3544    
3545                    Session session = null;
3546    
3547                    try {
3548                            session = openSession();
3549    
3550                            JournalArticle[] array = new JournalArticleImpl[3];
3551    
3552                            array[0] = getByStructureId_PrevAndNext(session, journalArticle,
3553                                            structureId, orderByComparator, true);
3554    
3555                            array[1] = journalArticle;
3556    
3557                            array[2] = getByStructureId_PrevAndNext(session, journalArticle,
3558                                            structureId, orderByComparator, false);
3559    
3560                            return array;
3561                    }
3562                    catch (Exception e) {
3563                            throw processException(e);
3564                    }
3565                    finally {
3566                            closeSession(session);
3567                    }
3568            }
3569    
3570            protected JournalArticle getByStructureId_PrevAndNext(Session session,
3571                    JournalArticle journalArticle, String structureId,
3572                    OrderByComparator orderByComparator, boolean previous) {
3573                    StringBundler query = null;
3574    
3575                    if (orderByComparator != null) {
3576                            query = new StringBundler(6 +
3577                                            (orderByComparator.getOrderByFields().length * 6));
3578                    }
3579                    else {
3580                            query = new StringBundler(3);
3581                    }
3582    
3583                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3584    
3585                    boolean bindStructureId = false;
3586    
3587                    if (structureId == null) {
3588                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
3589                    }
3590                    else if (structureId.equals(StringPool.BLANK)) {
3591                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
3592                    }
3593                    else {
3594                            bindStructureId = true;
3595    
3596                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
3597                    }
3598    
3599                    if (orderByComparator != null) {
3600                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3601    
3602                            if (orderByConditionFields.length > 0) {
3603                                    query.append(WHERE_AND);
3604                            }
3605    
3606                            for (int i = 0; i < orderByConditionFields.length; i++) {
3607                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3608                                    query.append(orderByConditionFields[i]);
3609    
3610                                    if ((i + 1) < orderByConditionFields.length) {
3611                                            if (orderByComparator.isAscending() ^ previous) {
3612                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3613                                            }
3614                                            else {
3615                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3616                                            }
3617                                    }
3618                                    else {
3619                                            if (orderByComparator.isAscending() ^ previous) {
3620                                                    query.append(WHERE_GREATER_THAN);
3621                                            }
3622                                            else {
3623                                                    query.append(WHERE_LESSER_THAN);
3624                                            }
3625                                    }
3626                            }
3627    
3628                            query.append(ORDER_BY_CLAUSE);
3629    
3630                            String[] orderByFields = orderByComparator.getOrderByFields();
3631    
3632                            for (int i = 0; i < orderByFields.length; i++) {
3633                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3634                                    query.append(orderByFields[i]);
3635    
3636                                    if ((i + 1) < orderByFields.length) {
3637                                            if (orderByComparator.isAscending() ^ previous) {
3638                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3639                                            }
3640                                            else {
3641                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3642                                            }
3643                                    }
3644                                    else {
3645                                            if (orderByComparator.isAscending() ^ previous) {
3646                                                    query.append(ORDER_BY_ASC);
3647                                            }
3648                                            else {
3649                                                    query.append(ORDER_BY_DESC);
3650                                            }
3651                                    }
3652                            }
3653                    }
3654                    else {
3655                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3656                    }
3657    
3658                    String sql = query.toString();
3659    
3660                    Query q = session.createQuery(sql);
3661    
3662                    q.setFirstResult(0);
3663                    q.setMaxResults(2);
3664    
3665                    QueryPos qPos = QueryPos.getInstance(q);
3666    
3667                    if (bindStructureId) {
3668                            qPos.add(structureId);
3669                    }
3670    
3671                    if (orderByComparator != null) {
3672                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
3673    
3674                            for (Object value : values) {
3675                                    qPos.add(value);
3676                            }
3677                    }
3678    
3679                    List<JournalArticle> list = q.list();
3680    
3681                    if (list.size() == 2) {
3682                            return list.get(1);
3683                    }
3684                    else {
3685                            return null;
3686                    }
3687            }
3688    
3689            /**
3690             * Removes all the journal articles where structureId = &#63; from the database.
3691             *
3692             * @param structureId the structure ID
3693             * @throws SystemException if a system exception occurred
3694             */
3695            public void removeByStructureId(String structureId)
3696                    throws SystemException {
3697                    for (JournalArticle journalArticle : findByStructureId(structureId,
3698                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3699                            remove(journalArticle);
3700                    }
3701            }
3702    
3703            /**
3704             * Returns the number of journal articles where structureId = &#63;.
3705             *
3706             * @param structureId the structure ID
3707             * @return the number of matching journal articles
3708             * @throws SystemException if a system exception occurred
3709             */
3710            public int countByStructureId(String structureId) throws SystemException {
3711                    FinderPath finderPath = FINDER_PATH_COUNT_BY_STRUCTUREID;
3712    
3713                    Object[] finderArgs = new Object[] { structureId };
3714    
3715                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3716                                    this);
3717    
3718                    if (count == null) {
3719                            StringBundler query = new StringBundler(2);
3720    
3721                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
3722    
3723                            boolean bindStructureId = false;
3724    
3725                            if (structureId == null) {
3726                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
3727                            }
3728                            else if (structureId.equals(StringPool.BLANK)) {
3729                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
3730                            }
3731                            else {
3732                                    bindStructureId = true;
3733    
3734                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
3735                            }
3736    
3737                            String sql = query.toString();
3738    
3739                            Session session = null;
3740    
3741                            try {
3742                                    session = openSession();
3743    
3744                                    Query q = session.createQuery(sql);
3745    
3746                                    QueryPos qPos = QueryPos.getInstance(q);
3747    
3748                                    if (bindStructureId) {
3749                                            qPos.add(structureId);
3750                                    }
3751    
3752                                    count = (Long)q.uniqueResult();
3753    
3754                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3755                            }
3756                            catch (Exception e) {
3757                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3758    
3759                                    throw processException(e);
3760                            }
3761                            finally {
3762                                    closeSession(session);
3763                            }
3764                    }
3765    
3766                    return count.intValue();
3767            }
3768    
3769            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
3770            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2 = "journalArticle.structureId = ?";
3771            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = '')";
3772            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_TEMPLATEID =
3773                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3774                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
3775                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
3776                            "findByTemplateId",
3777                            new String[] {
3778                                    String.class.getName(),
3779                                    
3780                            Integer.class.getName(), Integer.class.getName(),
3781                                    OrderByComparator.class.getName()
3782                            });
3783            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID =
3784                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3785                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
3786                            JournalArticleImpl.class,
3787                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByTemplateId",
3788                            new String[] { String.class.getName() },
3789                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK |
3790                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
3791                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
3792            public static final FinderPath FINDER_PATH_COUNT_BY_TEMPLATEID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3793                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
3794                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByTemplateId",
3795                            new String[] { String.class.getName() });
3796    
3797            /**
3798             * Returns all the journal articles where templateId = &#63;.
3799             *
3800             * @param templateId the template ID
3801             * @return the matching journal articles
3802             * @throws SystemException if a system exception occurred
3803             */
3804            public List<JournalArticle> findByTemplateId(String templateId)
3805                    throws SystemException {
3806                    return findByTemplateId(templateId, QueryUtil.ALL_POS,
3807                            QueryUtil.ALL_POS, null);
3808            }
3809    
3810            /**
3811             * Returns a range of all the journal articles where templateId = &#63;.
3812             *
3813             * <p>
3814             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3815             * </p>
3816             *
3817             * @param templateId the template ID
3818             * @param start the lower bound of the range of journal articles
3819             * @param end the upper bound of the range of journal articles (not inclusive)
3820             * @return the range of matching journal articles
3821             * @throws SystemException if a system exception occurred
3822             */
3823            public List<JournalArticle> findByTemplateId(String templateId, int start,
3824                    int end) throws SystemException {
3825                    return findByTemplateId(templateId, start, end, null);
3826            }
3827    
3828            /**
3829             * Returns an ordered range of all the journal articles where templateId = &#63;.
3830             *
3831             * <p>
3832             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3833             * </p>
3834             *
3835             * @param templateId the template ID
3836             * @param start the lower bound of the range of journal articles
3837             * @param end the upper bound of the range of journal articles (not inclusive)
3838             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3839             * @return the ordered range of matching journal articles
3840             * @throws SystemException if a system exception occurred
3841             */
3842            public List<JournalArticle> findByTemplateId(String templateId, int start,
3843                    int end, OrderByComparator orderByComparator) throws SystemException {
3844                    boolean pagination = true;
3845                    FinderPath finderPath = null;
3846                    Object[] finderArgs = null;
3847    
3848                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3849                                    (orderByComparator == null)) {
3850                            pagination = false;
3851                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID;
3852                            finderArgs = new Object[] { templateId };
3853                    }
3854                    else {
3855                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_TEMPLATEID;
3856                            finderArgs = new Object[] { templateId, start, end, orderByComparator };
3857                    }
3858    
3859                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
3860                                    finderArgs, this);
3861    
3862                    if ((list != null) && !list.isEmpty()) {
3863                            for (JournalArticle journalArticle : list) {
3864                                    if (!Validator.equals(templateId, journalArticle.getTemplateId())) {
3865                                            list = null;
3866    
3867                                            break;
3868                                    }
3869                            }
3870                    }
3871    
3872                    if (list == null) {
3873                            StringBundler query = null;
3874    
3875                            if (orderByComparator != null) {
3876                                    query = new StringBundler(3 +
3877                                                    (orderByComparator.getOrderByFields().length * 3));
3878                            }
3879                            else {
3880                                    query = new StringBundler(3);
3881                            }
3882    
3883                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3884    
3885                            boolean bindTemplateId = false;
3886    
3887                            if (templateId == null) {
3888                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
3889                            }
3890                            else if (templateId.equals(StringPool.BLANK)) {
3891                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
3892                            }
3893                            else {
3894                                    bindTemplateId = true;
3895    
3896                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
3897                            }
3898    
3899                            if (orderByComparator != null) {
3900                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3901                                            orderByComparator);
3902                            }
3903                            else
3904                             if (pagination) {
3905                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3906                            }
3907    
3908                            String sql = query.toString();
3909    
3910                            Session session = null;
3911    
3912                            try {
3913                                    session = openSession();
3914    
3915                                    Query q = session.createQuery(sql);
3916    
3917                                    QueryPos qPos = QueryPos.getInstance(q);
3918    
3919                                    if (bindTemplateId) {
3920                                            qPos.add(templateId);
3921                                    }
3922    
3923                                    if (!pagination) {
3924                                            list = (List<JournalArticle>)QueryUtil.list(q,
3925                                                            getDialect(), start, end, false);
3926    
3927                                            Collections.sort(list);
3928    
3929                                            list = new UnmodifiableList<JournalArticle>(list);
3930                                    }
3931                                    else {
3932                                            list = (List<JournalArticle>)QueryUtil.list(q,
3933                                                            getDialect(), start, end);
3934                                    }
3935    
3936                                    cacheResult(list);
3937    
3938                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3939                            }
3940                            catch (Exception e) {
3941                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3942    
3943                                    throw processException(e);
3944                            }
3945                            finally {
3946                                    closeSession(session);
3947                            }
3948                    }
3949    
3950                    return list;
3951            }
3952    
3953            /**
3954             * Returns the first journal article in the ordered set where templateId = &#63;.
3955             *
3956             * @param templateId the template ID
3957             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3958             * @return the first matching journal article
3959             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3960             * @throws SystemException if a system exception occurred
3961             */
3962            public JournalArticle findByTemplateId_First(String templateId,
3963                    OrderByComparator orderByComparator)
3964                    throws NoSuchArticleException, SystemException {
3965                    JournalArticle journalArticle = fetchByTemplateId_First(templateId,
3966                                    orderByComparator);
3967    
3968                    if (journalArticle != null) {
3969                            return journalArticle;
3970                    }
3971    
3972                    StringBundler msg = new StringBundler(4);
3973    
3974                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3975    
3976                    msg.append("templateId=");
3977                    msg.append(templateId);
3978    
3979                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3980    
3981                    throw new NoSuchArticleException(msg.toString());
3982            }
3983    
3984            /**
3985             * Returns the first journal article in the ordered set where templateId = &#63;.
3986             *
3987             * @param templateId the template ID
3988             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3989             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
3990             * @throws SystemException if a system exception occurred
3991             */
3992            public JournalArticle fetchByTemplateId_First(String templateId,
3993                    OrderByComparator orderByComparator) throws SystemException {
3994                    List<JournalArticle> list = findByTemplateId(templateId, 0, 1,
3995                                    orderByComparator);
3996    
3997                    if (!list.isEmpty()) {
3998                            return list.get(0);
3999                    }
4000    
4001                    return null;
4002            }
4003    
4004            /**
4005             * Returns the last journal article in the ordered set where templateId = &#63;.
4006             *
4007             * @param templateId the template ID
4008             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4009             * @return the last matching journal article
4010             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4011             * @throws SystemException if a system exception occurred
4012             */
4013            public JournalArticle findByTemplateId_Last(String templateId,
4014                    OrderByComparator orderByComparator)
4015                    throws NoSuchArticleException, SystemException {
4016                    JournalArticle journalArticle = fetchByTemplateId_Last(templateId,
4017                                    orderByComparator);
4018    
4019                    if (journalArticle != null) {
4020                            return journalArticle;
4021                    }
4022    
4023                    StringBundler msg = new StringBundler(4);
4024    
4025                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4026    
4027                    msg.append("templateId=");
4028                    msg.append(templateId);
4029    
4030                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4031    
4032                    throw new NoSuchArticleException(msg.toString());
4033            }
4034    
4035            /**
4036             * Returns the last journal article in the ordered set where templateId = &#63;.
4037             *
4038             * @param templateId the template ID
4039             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4040             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
4041             * @throws SystemException if a system exception occurred
4042             */
4043            public JournalArticle fetchByTemplateId_Last(String templateId,
4044                    OrderByComparator orderByComparator) throws SystemException {
4045                    int count = countByTemplateId(templateId);
4046    
4047                    List<JournalArticle> list = findByTemplateId(templateId, count - 1,
4048                                    count, orderByComparator);
4049    
4050                    if (!list.isEmpty()) {
4051                            return list.get(0);
4052                    }
4053    
4054                    return null;
4055            }
4056    
4057            /**
4058             * Returns the journal articles before and after the current journal article in the ordered set where templateId = &#63;.
4059             *
4060             * @param id the primary key of the current journal article
4061             * @param templateId the template ID
4062             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4063             * @return the previous, current, and next journal article
4064             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
4065             * @throws SystemException if a system exception occurred
4066             */
4067            public JournalArticle[] findByTemplateId_PrevAndNext(long id,
4068                    String templateId, OrderByComparator orderByComparator)
4069                    throws NoSuchArticleException, SystemException {
4070                    JournalArticle journalArticle = findByPrimaryKey(id);
4071    
4072                    Session session = null;
4073    
4074                    try {
4075                            session = openSession();
4076    
4077                            JournalArticle[] array = new JournalArticleImpl[3];
4078    
4079                            array[0] = getByTemplateId_PrevAndNext(session, journalArticle,
4080                                            templateId, orderByComparator, true);
4081    
4082                            array[1] = journalArticle;
4083    
4084                            array[2] = getByTemplateId_PrevAndNext(session, journalArticle,
4085                                            templateId, orderByComparator, false);
4086    
4087                            return array;
4088                    }
4089                    catch (Exception e) {
4090                            throw processException(e);
4091                    }
4092                    finally {
4093                            closeSession(session);
4094                    }
4095            }
4096    
4097            protected JournalArticle getByTemplateId_PrevAndNext(Session session,
4098                    JournalArticle journalArticle, String templateId,
4099                    OrderByComparator orderByComparator, boolean previous) {
4100                    StringBundler query = null;
4101    
4102                    if (orderByComparator != null) {
4103                            query = new StringBundler(6 +
4104                                            (orderByComparator.getOrderByFields().length * 6));
4105                    }
4106                    else {
4107                            query = new StringBundler(3);
4108                    }
4109    
4110                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4111    
4112                    boolean bindTemplateId = false;
4113    
4114                    if (templateId == null) {
4115                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
4116                    }
4117                    else if (templateId.equals(StringPool.BLANK)) {
4118                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
4119                    }
4120                    else {
4121                            bindTemplateId = true;
4122    
4123                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
4124                    }
4125    
4126                    if (orderByComparator != null) {
4127                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4128    
4129                            if (orderByConditionFields.length > 0) {
4130                                    query.append(WHERE_AND);
4131                            }
4132    
4133                            for (int i = 0; i < orderByConditionFields.length; i++) {
4134                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4135                                    query.append(orderByConditionFields[i]);
4136    
4137                                    if ((i + 1) < orderByConditionFields.length) {
4138                                            if (orderByComparator.isAscending() ^ previous) {
4139                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4140                                            }
4141                                            else {
4142                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4143                                            }
4144                                    }
4145                                    else {
4146                                            if (orderByComparator.isAscending() ^ previous) {
4147                                                    query.append(WHERE_GREATER_THAN);
4148                                            }
4149                                            else {
4150                                                    query.append(WHERE_LESSER_THAN);
4151                                            }
4152                                    }
4153                            }
4154    
4155                            query.append(ORDER_BY_CLAUSE);
4156    
4157                            String[] orderByFields = orderByComparator.getOrderByFields();
4158    
4159                            for (int i = 0; i < orderByFields.length; i++) {
4160                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4161                                    query.append(orderByFields[i]);
4162    
4163                                    if ((i + 1) < orderByFields.length) {
4164                                            if (orderByComparator.isAscending() ^ previous) {
4165                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4166                                            }
4167                                            else {
4168                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4169                                            }
4170                                    }
4171                                    else {
4172                                            if (orderByComparator.isAscending() ^ previous) {
4173                                                    query.append(ORDER_BY_ASC);
4174                                            }
4175                                            else {
4176                                                    query.append(ORDER_BY_DESC);
4177                                            }
4178                                    }
4179                            }
4180                    }
4181                    else {
4182                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4183                    }
4184    
4185                    String sql = query.toString();
4186    
4187                    Query q = session.createQuery(sql);
4188    
4189                    q.setFirstResult(0);
4190                    q.setMaxResults(2);
4191    
4192                    QueryPos qPos = QueryPos.getInstance(q);
4193    
4194                    if (bindTemplateId) {
4195                            qPos.add(templateId);
4196                    }
4197    
4198                    if (orderByComparator != null) {
4199                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
4200    
4201                            for (Object value : values) {
4202                                    qPos.add(value);
4203                            }
4204                    }
4205    
4206                    List<JournalArticle> list = q.list();
4207    
4208                    if (list.size() == 2) {
4209                            return list.get(1);
4210                    }
4211                    else {
4212                            return null;
4213                    }
4214            }
4215    
4216            /**
4217             * Removes all the journal articles where templateId = &#63; from the database.
4218             *
4219             * @param templateId the template ID
4220             * @throws SystemException if a system exception occurred
4221             */
4222            public void removeByTemplateId(String templateId) throws SystemException {
4223                    for (JournalArticle journalArticle : findByTemplateId(templateId,
4224                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4225                            remove(journalArticle);
4226                    }
4227            }
4228    
4229            /**
4230             * Returns the number of journal articles where templateId = &#63;.
4231             *
4232             * @param templateId the template ID
4233             * @return the number of matching journal articles
4234             * @throws SystemException if a system exception occurred
4235             */
4236            public int countByTemplateId(String templateId) throws SystemException {
4237                    FinderPath finderPath = FINDER_PATH_COUNT_BY_TEMPLATEID;
4238    
4239                    Object[] finderArgs = new Object[] { templateId };
4240    
4241                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4242                                    this);
4243    
4244                    if (count == null) {
4245                            StringBundler query = new StringBundler(2);
4246    
4247                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
4248    
4249                            boolean bindTemplateId = false;
4250    
4251                            if (templateId == null) {
4252                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
4253                            }
4254                            else if (templateId.equals(StringPool.BLANK)) {
4255                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
4256                            }
4257                            else {
4258                                    bindTemplateId = true;
4259    
4260                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
4261                            }
4262    
4263                            String sql = query.toString();
4264    
4265                            Session session = null;
4266    
4267                            try {
4268                                    session = openSession();
4269    
4270                                    Query q = session.createQuery(sql);
4271    
4272                                    QueryPos qPos = QueryPos.getInstance(q);
4273    
4274                                    if (bindTemplateId) {
4275                                            qPos.add(templateId);
4276                                    }
4277    
4278                                    count = (Long)q.uniqueResult();
4279    
4280                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4281                            }
4282                            catch (Exception e) {
4283                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4284    
4285                                    throw processException(e);
4286                            }
4287                            finally {
4288                                    closeSession(session);
4289                            }
4290                    }
4291    
4292                    return count.intValue();
4293            }
4294    
4295            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
4296            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2 = "journalArticle.templateId = ?";
4297            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = '')";
4298            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTUUID =
4299                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4300                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4301                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
4302                            "findByLayoutUuid",
4303                            new String[] {
4304                                    String.class.getName(),
4305                                    
4306                            Integer.class.getName(), Integer.class.getName(),
4307                                    OrderByComparator.class.getName()
4308                            });
4309            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID =
4310                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4311                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4312                            JournalArticleImpl.class,
4313                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByLayoutUuid",
4314                            new String[] { String.class.getName() },
4315                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK |
4316                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
4317                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
4318            public static final FinderPath FINDER_PATH_COUNT_BY_LAYOUTUUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4319                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
4320                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByLayoutUuid",
4321                            new String[] { String.class.getName() });
4322    
4323            /**
4324             * Returns all the journal articles where layoutUuid = &#63;.
4325             *
4326             * @param layoutUuid the layout uuid
4327             * @return the matching journal articles
4328             * @throws SystemException if a system exception occurred
4329             */
4330            public List<JournalArticle> findByLayoutUuid(String layoutUuid)
4331                    throws SystemException {
4332                    return findByLayoutUuid(layoutUuid, QueryUtil.ALL_POS,
4333                            QueryUtil.ALL_POS, null);
4334            }
4335    
4336            /**
4337             * Returns a range of all the journal articles where layoutUuid = &#63;.
4338             *
4339             * <p>
4340             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4341             * </p>
4342             *
4343             * @param layoutUuid the layout uuid
4344             * @param start the lower bound of the range of journal articles
4345             * @param end the upper bound of the range of journal articles (not inclusive)
4346             * @return the range of matching journal articles
4347             * @throws SystemException if a system exception occurred
4348             */
4349            public List<JournalArticle> findByLayoutUuid(String layoutUuid, int start,
4350                    int end) throws SystemException {
4351                    return findByLayoutUuid(layoutUuid, start, end, null);
4352            }
4353    
4354            /**
4355             * Returns an ordered range of all the journal articles where layoutUuid = &#63;.
4356             *
4357             * <p>
4358             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4359             * </p>
4360             *
4361             * @param layoutUuid the layout uuid
4362             * @param start the lower bound of the range of journal articles
4363             * @param end the upper bound of the range of journal articles (not inclusive)
4364             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4365             * @return the ordered range of matching journal articles
4366             * @throws SystemException if a system exception occurred
4367             */
4368            public List<JournalArticle> findByLayoutUuid(String layoutUuid, int start,
4369                    int end, OrderByComparator orderByComparator) throws SystemException {
4370                    boolean pagination = true;
4371                    FinderPath finderPath = null;
4372                    Object[] finderArgs = null;
4373    
4374                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4375                                    (orderByComparator == null)) {
4376                            pagination = false;
4377                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID;
4378                            finderArgs = new Object[] { layoutUuid };
4379                    }
4380                    else {
4381                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTUUID;
4382                            finderArgs = new Object[] { layoutUuid, start, end, orderByComparator };
4383                    }
4384    
4385                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
4386                                    finderArgs, this);
4387    
4388                    if ((list != null) && !list.isEmpty()) {
4389                            for (JournalArticle journalArticle : list) {
4390                                    if (!Validator.equals(layoutUuid, journalArticle.getLayoutUuid())) {
4391                                            list = null;
4392    
4393                                            break;
4394                                    }
4395                            }
4396                    }
4397    
4398                    if (list == null) {
4399                            StringBundler query = null;
4400    
4401                            if (orderByComparator != null) {
4402                                    query = new StringBundler(3 +
4403                                                    (orderByComparator.getOrderByFields().length * 3));
4404                            }
4405                            else {
4406                                    query = new StringBundler(3);
4407                            }
4408    
4409                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4410    
4411                            boolean bindLayoutUuid = false;
4412    
4413                            if (layoutUuid == null) {
4414                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
4415                            }
4416                            else if (layoutUuid.equals(StringPool.BLANK)) {
4417                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
4418                            }
4419                            else {
4420                                    bindLayoutUuid = true;
4421    
4422                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
4423                            }
4424    
4425                            if (orderByComparator != null) {
4426                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4427                                            orderByComparator);
4428                            }
4429                            else
4430                             if (pagination) {
4431                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4432                            }
4433    
4434                            String sql = query.toString();
4435    
4436                            Session session = null;
4437    
4438                            try {
4439                                    session = openSession();
4440    
4441                                    Query q = session.createQuery(sql);
4442    
4443                                    QueryPos qPos = QueryPos.getInstance(q);
4444    
4445                                    if (bindLayoutUuid) {
4446                                            qPos.add(layoutUuid);
4447                                    }
4448    
4449                                    if (!pagination) {
4450                                            list = (List<JournalArticle>)QueryUtil.list(q,
4451                                                            getDialect(), start, end, false);
4452    
4453                                            Collections.sort(list);
4454    
4455                                            list = new UnmodifiableList<JournalArticle>(list);
4456                                    }
4457                                    else {
4458                                            list = (List<JournalArticle>)QueryUtil.list(q,
4459                                                            getDialect(), start, end);
4460                                    }
4461    
4462                                    cacheResult(list);
4463    
4464                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4465                            }
4466                            catch (Exception e) {
4467                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4468    
4469                                    throw processException(e);
4470                            }
4471                            finally {
4472                                    closeSession(session);
4473                            }
4474                    }
4475    
4476                    return list;
4477            }
4478    
4479            /**
4480             * Returns the first journal article in the ordered set where layoutUuid = &#63;.
4481             *
4482             * @param layoutUuid the layout uuid
4483             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4484             * @return the first matching journal article
4485             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4486             * @throws SystemException if a system exception occurred
4487             */
4488            public JournalArticle findByLayoutUuid_First(String layoutUuid,
4489                    OrderByComparator orderByComparator)
4490                    throws NoSuchArticleException, SystemException {
4491                    JournalArticle journalArticle = fetchByLayoutUuid_First(layoutUuid,
4492                                    orderByComparator);
4493    
4494                    if (journalArticle != null) {
4495                            return journalArticle;
4496                    }
4497    
4498                    StringBundler msg = new StringBundler(4);
4499    
4500                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4501    
4502                    msg.append("layoutUuid=");
4503                    msg.append(layoutUuid);
4504    
4505                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4506    
4507                    throw new NoSuchArticleException(msg.toString());
4508            }
4509    
4510            /**
4511             * Returns the first journal article in the ordered set where layoutUuid = &#63;.
4512             *
4513             * @param layoutUuid the layout uuid
4514             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4515             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
4516             * @throws SystemException if a system exception occurred
4517             */
4518            public JournalArticle fetchByLayoutUuid_First(String layoutUuid,
4519                    OrderByComparator orderByComparator) throws SystemException {
4520                    List<JournalArticle> list = findByLayoutUuid(layoutUuid, 0, 1,
4521                                    orderByComparator);
4522    
4523                    if (!list.isEmpty()) {
4524                            return list.get(0);
4525                    }
4526    
4527                    return null;
4528            }
4529    
4530            /**
4531             * Returns the last journal article in the ordered set where layoutUuid = &#63;.
4532             *
4533             * @param layoutUuid the layout uuid
4534             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4535             * @return the last matching journal article
4536             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4537             * @throws SystemException if a system exception occurred
4538             */
4539            public JournalArticle findByLayoutUuid_Last(String layoutUuid,
4540                    OrderByComparator orderByComparator)
4541                    throws NoSuchArticleException, SystemException {
4542                    JournalArticle journalArticle = fetchByLayoutUuid_Last(layoutUuid,
4543                                    orderByComparator);
4544    
4545                    if (journalArticle != null) {
4546                            return journalArticle;
4547                    }
4548    
4549                    StringBundler msg = new StringBundler(4);
4550    
4551                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4552    
4553                    msg.append("layoutUuid=");
4554                    msg.append(layoutUuid);
4555    
4556                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4557    
4558                    throw new NoSuchArticleException(msg.toString());
4559            }
4560    
4561            /**
4562             * Returns the last journal article in the ordered set where layoutUuid = &#63;.
4563             *
4564             * @param layoutUuid the layout uuid
4565             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4566             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
4567             * @throws SystemException if a system exception occurred
4568             */
4569            public JournalArticle fetchByLayoutUuid_Last(String layoutUuid,
4570                    OrderByComparator orderByComparator) throws SystemException {
4571                    int count = countByLayoutUuid(layoutUuid);
4572    
4573                    List<JournalArticle> list = findByLayoutUuid(layoutUuid, count - 1,
4574                                    count, orderByComparator);
4575    
4576                    if (!list.isEmpty()) {
4577                            return list.get(0);
4578                    }
4579    
4580                    return null;
4581            }
4582    
4583            /**
4584             * Returns the journal articles before and after the current journal article in the ordered set where layoutUuid = &#63;.
4585             *
4586             * @param id the primary key of the current journal article
4587             * @param layoutUuid the layout uuid
4588             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4589             * @return the previous, current, and next journal article
4590             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
4591             * @throws SystemException if a system exception occurred
4592             */
4593            public JournalArticle[] findByLayoutUuid_PrevAndNext(long id,
4594                    String layoutUuid, OrderByComparator orderByComparator)
4595                    throws NoSuchArticleException, SystemException {
4596                    JournalArticle journalArticle = findByPrimaryKey(id);
4597    
4598                    Session session = null;
4599    
4600                    try {
4601                            session = openSession();
4602    
4603                            JournalArticle[] array = new JournalArticleImpl[3];
4604    
4605                            array[0] = getByLayoutUuid_PrevAndNext(session, journalArticle,
4606                                            layoutUuid, orderByComparator, true);
4607    
4608                            array[1] = journalArticle;
4609    
4610                            array[2] = getByLayoutUuid_PrevAndNext(session, journalArticle,
4611                                            layoutUuid, orderByComparator, false);
4612    
4613                            return array;
4614                    }
4615                    catch (Exception e) {
4616                            throw processException(e);
4617                    }
4618                    finally {
4619                            closeSession(session);
4620                    }
4621            }
4622    
4623            protected JournalArticle getByLayoutUuid_PrevAndNext(Session session,
4624                    JournalArticle journalArticle, String layoutUuid,
4625                    OrderByComparator orderByComparator, boolean previous) {
4626                    StringBundler query = null;
4627    
4628                    if (orderByComparator != null) {
4629                            query = new StringBundler(6 +
4630                                            (orderByComparator.getOrderByFields().length * 6));
4631                    }
4632                    else {
4633                            query = new StringBundler(3);
4634                    }
4635    
4636                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4637    
4638                    boolean bindLayoutUuid = false;
4639    
4640                    if (layoutUuid == null) {
4641                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
4642                    }
4643                    else if (layoutUuid.equals(StringPool.BLANK)) {
4644                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
4645                    }
4646                    else {
4647                            bindLayoutUuid = true;
4648    
4649                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
4650                    }
4651    
4652                    if (orderByComparator != null) {
4653                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4654    
4655                            if (orderByConditionFields.length > 0) {
4656                                    query.append(WHERE_AND);
4657                            }
4658    
4659                            for (int i = 0; i < orderByConditionFields.length; i++) {
4660                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4661                                    query.append(orderByConditionFields[i]);
4662    
4663                                    if ((i + 1) < orderByConditionFields.length) {
4664                                            if (orderByComparator.isAscending() ^ previous) {
4665                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4666                                            }
4667                                            else {
4668                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4669                                            }
4670                                    }
4671                                    else {
4672                                            if (orderByComparator.isAscending() ^ previous) {
4673                                                    query.append(WHERE_GREATER_THAN);
4674                                            }
4675                                            else {
4676                                                    query.append(WHERE_LESSER_THAN);
4677                                            }
4678                                    }
4679                            }
4680    
4681                            query.append(ORDER_BY_CLAUSE);
4682    
4683                            String[] orderByFields = orderByComparator.getOrderByFields();
4684    
4685                            for (int i = 0; i < orderByFields.length; i++) {
4686                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4687                                    query.append(orderByFields[i]);
4688    
4689                                    if ((i + 1) < orderByFields.length) {
4690                                            if (orderByComparator.isAscending() ^ previous) {
4691                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4692                                            }
4693                                            else {
4694                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4695                                            }
4696                                    }
4697                                    else {
4698                                            if (orderByComparator.isAscending() ^ previous) {
4699                                                    query.append(ORDER_BY_ASC);
4700                                            }
4701                                            else {
4702                                                    query.append(ORDER_BY_DESC);
4703                                            }
4704                                    }
4705                            }
4706                    }
4707                    else {
4708                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4709                    }
4710    
4711                    String sql = query.toString();
4712    
4713                    Query q = session.createQuery(sql);
4714    
4715                    q.setFirstResult(0);
4716                    q.setMaxResults(2);
4717    
4718                    QueryPos qPos = QueryPos.getInstance(q);
4719    
4720                    if (bindLayoutUuid) {
4721                            qPos.add(layoutUuid);
4722                    }
4723    
4724                    if (orderByComparator != null) {
4725                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
4726    
4727                            for (Object value : values) {
4728                                    qPos.add(value);
4729                            }
4730                    }
4731    
4732                    List<JournalArticle> list = q.list();
4733    
4734                    if (list.size() == 2) {
4735                            return list.get(1);
4736                    }
4737                    else {
4738                            return null;
4739                    }
4740            }
4741    
4742            /**
4743             * Removes all the journal articles where layoutUuid = &#63; from the database.
4744             *
4745             * @param layoutUuid the layout uuid
4746             * @throws SystemException if a system exception occurred
4747             */
4748            public void removeByLayoutUuid(String layoutUuid) throws SystemException {
4749                    for (JournalArticle journalArticle : findByLayoutUuid(layoutUuid,
4750                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4751                            remove(journalArticle);
4752                    }
4753            }
4754    
4755            /**
4756             * Returns the number of journal articles where layoutUuid = &#63;.
4757             *
4758             * @param layoutUuid the layout uuid
4759             * @return the number of matching journal articles
4760             * @throws SystemException if a system exception occurred
4761             */
4762            public int countByLayoutUuid(String layoutUuid) throws SystemException {
4763                    FinderPath finderPath = FINDER_PATH_COUNT_BY_LAYOUTUUID;
4764    
4765                    Object[] finderArgs = new Object[] { layoutUuid };
4766    
4767                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4768                                    this);
4769    
4770                    if (count == null) {
4771                            StringBundler query = new StringBundler(2);
4772    
4773                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
4774    
4775                            boolean bindLayoutUuid = false;
4776    
4777                            if (layoutUuid == null) {
4778                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
4779                            }
4780                            else if (layoutUuid.equals(StringPool.BLANK)) {
4781                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
4782                            }
4783                            else {
4784                                    bindLayoutUuid = true;
4785    
4786                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
4787                            }
4788    
4789                            String sql = query.toString();
4790    
4791                            Session session = null;
4792    
4793                            try {
4794                                    session = openSession();
4795    
4796                                    Query q = session.createQuery(sql);
4797    
4798                                    QueryPos qPos = QueryPos.getInstance(q);
4799    
4800                                    if (bindLayoutUuid) {
4801                                            qPos.add(layoutUuid);
4802                                    }
4803    
4804                                    count = (Long)q.uniqueResult();
4805    
4806                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4807                            }
4808                            catch (Exception e) {
4809                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4810    
4811                                    throw processException(e);
4812                            }
4813                            finally {
4814                                    closeSession(session);
4815                            }
4816                    }
4817    
4818                    return count.intValue();
4819            }
4820    
4821            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
4822            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
4823            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = '')";
4824            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_SMALLIMAGEID =
4825                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4826                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4827                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
4828                            "findBySmallImageId",
4829                            new String[] {
4830                                    Long.class.getName(),
4831                                    
4832                            Integer.class.getName(), Integer.class.getName(),
4833                                    OrderByComparator.class.getName()
4834                            });
4835            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID =
4836                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4837                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4838                            JournalArticleImpl.class,
4839                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findBySmallImageId",
4840                            new String[] { Long.class.getName() },
4841                            JournalArticleModelImpl.SMALLIMAGEID_COLUMN_BITMASK |
4842                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
4843                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
4844            public static final FinderPath FINDER_PATH_COUNT_BY_SMALLIMAGEID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4845                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
4846                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countBySmallImageId",
4847                            new String[] { Long.class.getName() });
4848    
4849            /**
4850             * Returns all the journal articles where smallImageId = &#63;.
4851             *
4852             * @param smallImageId the small image ID
4853             * @return the matching journal articles
4854             * @throws SystemException if a system exception occurred
4855             */
4856            public List<JournalArticle> findBySmallImageId(long smallImageId)
4857                    throws SystemException {
4858                    return findBySmallImageId(smallImageId, QueryUtil.ALL_POS,
4859                            QueryUtil.ALL_POS, null);
4860            }
4861    
4862            /**
4863             * Returns a range of all the journal articles where smallImageId = &#63;.
4864             *
4865             * <p>
4866             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4867             * </p>
4868             *
4869             * @param smallImageId the small image ID
4870             * @param start the lower bound of the range of journal articles
4871             * @param end the upper bound of the range of journal articles (not inclusive)
4872             * @return the range of matching journal articles
4873             * @throws SystemException if a system exception occurred
4874             */
4875            public List<JournalArticle> findBySmallImageId(long smallImageId,
4876                    int start, int end) throws SystemException {
4877                    return findBySmallImageId(smallImageId, start, end, null);
4878            }
4879    
4880            /**
4881             * Returns an ordered range of all the journal articles where smallImageId = &#63;.
4882             *
4883             * <p>
4884             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4885             * </p>
4886             *
4887             * @param smallImageId the small image ID
4888             * @param start the lower bound of the range of journal articles
4889             * @param end the upper bound of the range of journal articles (not inclusive)
4890             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4891             * @return the ordered range of matching journal articles
4892             * @throws SystemException if a system exception occurred
4893             */
4894            public List<JournalArticle> findBySmallImageId(long smallImageId,
4895                    int start, int end, OrderByComparator orderByComparator)
4896                    throws SystemException {
4897                    boolean pagination = true;
4898                    FinderPath finderPath = null;
4899                    Object[] finderArgs = null;
4900    
4901                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4902                                    (orderByComparator == null)) {
4903                            pagination = false;
4904                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID;
4905                            finderArgs = new Object[] { smallImageId };
4906                    }
4907                    else {
4908                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_SMALLIMAGEID;
4909                            finderArgs = new Object[] {
4910                                            smallImageId,
4911                                            
4912                                            start, end, orderByComparator
4913                                    };
4914                    }
4915    
4916                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
4917                                    finderArgs, this);
4918    
4919                    if ((list != null) && !list.isEmpty()) {
4920                            for (JournalArticle journalArticle : list) {
4921                                    if ((smallImageId != journalArticle.getSmallImageId())) {
4922                                            list = null;
4923    
4924                                            break;
4925                                    }
4926                            }
4927                    }
4928    
4929                    if (list == null) {
4930                            StringBundler query = null;
4931    
4932                            if (orderByComparator != null) {
4933                                    query = new StringBundler(3 +
4934                                                    (orderByComparator.getOrderByFields().length * 3));
4935                            }
4936                            else {
4937                                    query = new StringBundler(3);
4938                            }
4939    
4940                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4941    
4942                            query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
4943    
4944                            if (orderByComparator != null) {
4945                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4946                                            orderByComparator);
4947                            }
4948                            else
4949                             if (pagination) {
4950                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4951                            }
4952    
4953                            String sql = query.toString();
4954    
4955                            Session session = null;
4956    
4957                            try {
4958                                    session = openSession();
4959    
4960                                    Query q = session.createQuery(sql);
4961    
4962                                    QueryPos qPos = QueryPos.getInstance(q);
4963    
4964                                    qPos.add(smallImageId);
4965    
4966                                    if (!pagination) {
4967                                            list = (List<JournalArticle>)QueryUtil.list(q,
4968                                                            getDialect(), start, end, false);
4969    
4970                                            Collections.sort(list);
4971    
4972                                            list = new UnmodifiableList<JournalArticle>(list);
4973                                    }
4974                                    else {
4975                                            list = (List<JournalArticle>)QueryUtil.list(q,
4976                                                            getDialect(), start, end);
4977                                    }
4978    
4979                                    cacheResult(list);
4980    
4981                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4982                            }
4983                            catch (Exception e) {
4984                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4985    
4986                                    throw processException(e);
4987                            }
4988                            finally {
4989                                    closeSession(session);
4990                            }
4991                    }
4992    
4993                    return list;
4994            }
4995    
4996            /**
4997             * Returns the first journal article in the ordered set where smallImageId = &#63;.
4998             *
4999             * @param smallImageId the small image ID
5000             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5001             * @return the first matching journal article
5002             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5003             * @throws SystemException if a system exception occurred
5004             */
5005            public JournalArticle findBySmallImageId_First(long smallImageId,
5006                    OrderByComparator orderByComparator)
5007                    throws NoSuchArticleException, SystemException {
5008                    JournalArticle journalArticle = fetchBySmallImageId_First(smallImageId,
5009                                    orderByComparator);
5010    
5011                    if (journalArticle != null) {
5012                            return journalArticle;
5013                    }
5014    
5015                    StringBundler msg = new StringBundler(4);
5016    
5017                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5018    
5019                    msg.append("smallImageId=");
5020                    msg.append(smallImageId);
5021    
5022                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5023    
5024                    throw new NoSuchArticleException(msg.toString());
5025            }
5026    
5027            /**
5028             * Returns the first journal article in the ordered set where smallImageId = &#63;.
5029             *
5030             * @param smallImageId the small image ID
5031             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5032             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
5033             * @throws SystemException if a system exception occurred
5034             */
5035            public JournalArticle fetchBySmallImageId_First(long smallImageId,
5036                    OrderByComparator orderByComparator) throws SystemException {
5037                    List<JournalArticle> list = findBySmallImageId(smallImageId, 0, 1,
5038                                    orderByComparator);
5039    
5040                    if (!list.isEmpty()) {
5041                            return list.get(0);
5042                    }
5043    
5044                    return null;
5045            }
5046    
5047            /**
5048             * Returns the last journal article in the ordered set where smallImageId = &#63;.
5049             *
5050             * @param smallImageId the small image ID
5051             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5052             * @return the last matching journal article
5053             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5054             * @throws SystemException if a system exception occurred
5055             */
5056            public JournalArticle findBySmallImageId_Last(long smallImageId,
5057                    OrderByComparator orderByComparator)
5058                    throws NoSuchArticleException, SystemException {
5059                    JournalArticle journalArticle = fetchBySmallImageId_Last(smallImageId,
5060                                    orderByComparator);
5061    
5062                    if (journalArticle != null) {
5063                            return journalArticle;
5064                    }
5065    
5066                    StringBundler msg = new StringBundler(4);
5067    
5068                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5069    
5070                    msg.append("smallImageId=");
5071                    msg.append(smallImageId);
5072    
5073                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5074    
5075                    throw new NoSuchArticleException(msg.toString());
5076            }
5077    
5078            /**
5079             * Returns the last journal article in the ordered set where smallImageId = &#63;.
5080             *
5081             * @param smallImageId the small image ID
5082             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5083             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
5084             * @throws SystemException if a system exception occurred
5085             */
5086            public JournalArticle fetchBySmallImageId_Last(long smallImageId,
5087                    OrderByComparator orderByComparator) throws SystemException {
5088                    int count = countBySmallImageId(smallImageId);
5089    
5090                    List<JournalArticle> list = findBySmallImageId(smallImageId, count - 1,
5091                                    count, orderByComparator);
5092    
5093                    if (!list.isEmpty()) {
5094                            return list.get(0);
5095                    }
5096    
5097                    return null;
5098            }
5099    
5100            /**
5101             * Returns the journal articles before and after the current journal article in the ordered set where smallImageId = &#63;.
5102             *
5103             * @param id the primary key of the current journal article
5104             * @param smallImageId the small image ID
5105             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5106             * @return the previous, current, and next journal article
5107             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
5108             * @throws SystemException if a system exception occurred
5109             */
5110            public JournalArticle[] findBySmallImageId_PrevAndNext(long id,
5111                    long smallImageId, OrderByComparator orderByComparator)
5112                    throws NoSuchArticleException, SystemException {
5113                    JournalArticle journalArticle = findByPrimaryKey(id);
5114    
5115                    Session session = null;
5116    
5117                    try {
5118                            session = openSession();
5119    
5120                            JournalArticle[] array = new JournalArticleImpl[3];
5121    
5122                            array[0] = getBySmallImageId_PrevAndNext(session, journalArticle,
5123                                            smallImageId, orderByComparator, true);
5124    
5125                            array[1] = journalArticle;
5126    
5127                            array[2] = getBySmallImageId_PrevAndNext(session, journalArticle,
5128                                            smallImageId, orderByComparator, false);
5129    
5130                            return array;
5131                    }
5132                    catch (Exception e) {
5133                            throw processException(e);
5134                    }
5135                    finally {
5136                            closeSession(session);
5137                    }
5138            }
5139    
5140            protected JournalArticle getBySmallImageId_PrevAndNext(Session session,
5141                    JournalArticle journalArticle, long smallImageId,
5142                    OrderByComparator orderByComparator, boolean previous) {
5143                    StringBundler query = null;
5144    
5145                    if (orderByComparator != null) {
5146                            query = new StringBundler(6 +
5147                                            (orderByComparator.getOrderByFields().length * 6));
5148                    }
5149                    else {
5150                            query = new StringBundler(3);
5151                    }
5152    
5153                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5154    
5155                    query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
5156    
5157                    if (orderByComparator != null) {
5158                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5159    
5160                            if (orderByConditionFields.length > 0) {
5161                                    query.append(WHERE_AND);
5162                            }
5163    
5164                            for (int i = 0; i < orderByConditionFields.length; i++) {
5165                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5166                                    query.append(orderByConditionFields[i]);
5167    
5168                                    if ((i + 1) < orderByConditionFields.length) {
5169                                            if (orderByComparator.isAscending() ^ previous) {
5170                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5171                                            }
5172                                            else {
5173                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5174                                            }
5175                                    }
5176                                    else {
5177                                            if (orderByComparator.isAscending() ^ previous) {
5178                                                    query.append(WHERE_GREATER_THAN);
5179                                            }
5180                                            else {
5181                                                    query.append(WHERE_LESSER_THAN);
5182                                            }
5183                                    }
5184                            }
5185    
5186                            query.append(ORDER_BY_CLAUSE);
5187    
5188                            String[] orderByFields = orderByComparator.getOrderByFields();
5189    
5190                            for (int i = 0; i < orderByFields.length; i++) {
5191                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5192                                    query.append(orderByFields[i]);
5193    
5194                                    if ((i + 1) < orderByFields.length) {
5195                                            if (orderByComparator.isAscending() ^ previous) {
5196                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5197                                            }
5198                                            else {
5199                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5200                                            }
5201                                    }
5202                                    else {
5203                                            if (orderByComparator.isAscending() ^ previous) {
5204                                                    query.append(ORDER_BY_ASC);
5205                                            }
5206                                            else {
5207                                                    query.append(ORDER_BY_DESC);
5208                                            }
5209                                    }
5210                            }
5211                    }
5212                    else {
5213                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5214                    }
5215    
5216                    String sql = query.toString();
5217    
5218                    Query q = session.createQuery(sql);
5219    
5220                    q.setFirstResult(0);
5221                    q.setMaxResults(2);
5222    
5223                    QueryPos qPos = QueryPos.getInstance(q);
5224    
5225                    qPos.add(smallImageId);
5226    
5227                    if (orderByComparator != null) {
5228                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
5229    
5230                            for (Object value : values) {
5231                                    qPos.add(value);
5232                            }
5233                    }
5234    
5235                    List<JournalArticle> list = q.list();
5236    
5237                    if (list.size() == 2) {
5238                            return list.get(1);
5239                    }
5240                    else {
5241                            return null;
5242                    }
5243            }
5244    
5245            /**
5246             * Removes all the journal articles where smallImageId = &#63; from the database.
5247             *
5248             * @param smallImageId the small image ID
5249             * @throws SystemException if a system exception occurred
5250             */
5251            public void removeBySmallImageId(long smallImageId)
5252                    throws SystemException {
5253                    for (JournalArticle journalArticle : findBySmallImageId(smallImageId,
5254                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5255                            remove(journalArticle);
5256                    }
5257            }
5258    
5259            /**
5260             * Returns the number of journal articles where smallImageId = &#63;.
5261             *
5262             * @param smallImageId the small image ID
5263             * @return the number of matching journal articles
5264             * @throws SystemException if a system exception occurred
5265             */
5266            public int countBySmallImageId(long smallImageId) throws SystemException {
5267                    FinderPath finderPath = FINDER_PATH_COUNT_BY_SMALLIMAGEID;
5268    
5269                    Object[] finderArgs = new Object[] { smallImageId };
5270    
5271                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5272                                    this);
5273    
5274                    if (count == null) {
5275                            StringBundler query = new StringBundler(2);
5276    
5277                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
5278    
5279                            query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
5280    
5281                            String sql = query.toString();
5282    
5283                            Session session = null;
5284    
5285                            try {
5286                                    session = openSession();
5287    
5288                                    Query q = session.createQuery(sql);
5289    
5290                                    QueryPos qPos = QueryPos.getInstance(q);
5291    
5292                                    qPos.add(smallImageId);
5293    
5294                                    count = (Long)q.uniqueResult();
5295    
5296                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5297                            }
5298                            catch (Exception e) {
5299                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5300    
5301                                    throw processException(e);
5302                            }
5303                            finally {
5304                                    closeSession(session);
5305                            }
5306                    }
5307    
5308                    return count.intValue();
5309            }
5310    
5311            private static final String _FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2 = "journalArticle.smallImageId = ?";
5312            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5313                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5314                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5315                            "findByR_ST",
5316                            new String[] {
5317                                    Long.class.getName(), Integer.class.getName(),
5318                                    
5319                            Integer.class.getName(), Integer.class.getName(),
5320                                    OrderByComparator.class.getName()
5321                            });
5322            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5323                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5324                            JournalArticleImpl.class,
5325                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_ST",
5326                            new String[] { Long.class.getName(), Integer.class.getName() },
5327                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
5328                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
5329                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
5330                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
5331            public static final FinderPath FINDER_PATH_COUNT_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5332                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
5333                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_ST",
5334                            new String[] { Long.class.getName(), Integer.class.getName() });
5335    
5336            /**
5337             * Returns all the journal articles where resourcePrimKey = &#63; and status = &#63;.
5338             *
5339             * @param resourcePrimKey the resource prim key
5340             * @param status the status
5341             * @return the matching journal articles
5342             * @throws SystemException if a system exception occurred
5343             */
5344            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status)
5345                    throws SystemException {
5346                    return findByR_ST(resourcePrimKey, status, QueryUtil.ALL_POS,
5347                            QueryUtil.ALL_POS, null);
5348            }
5349    
5350            /**
5351             * Returns a range of all the journal articles where resourcePrimKey = &#63; and status = &#63;.
5352             *
5353             * <p>
5354             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5355             * </p>
5356             *
5357             * @param resourcePrimKey the resource prim key
5358             * @param status the status
5359             * @param start the lower bound of the range of journal articles
5360             * @param end the upper bound of the range of journal articles (not inclusive)
5361             * @return the range of matching journal articles
5362             * @throws SystemException if a system exception occurred
5363             */
5364            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status,
5365                    int start, int end) throws SystemException {
5366                    return findByR_ST(resourcePrimKey, status, start, end, null);
5367            }
5368    
5369            /**
5370             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and status = &#63;.
5371             *
5372             * <p>
5373             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5374             * </p>
5375             *
5376             * @param resourcePrimKey the resource prim key
5377             * @param status the status
5378             * @param start the lower bound of the range of journal articles
5379             * @param end the upper bound of the range of journal articles (not inclusive)
5380             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5381             * @return the ordered range of matching journal articles
5382             * @throws SystemException if a system exception occurred
5383             */
5384            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status,
5385                    int start, int end, OrderByComparator orderByComparator)
5386                    throws SystemException {
5387                    boolean pagination = true;
5388                    FinderPath finderPath = null;
5389                    Object[] finderArgs = null;
5390    
5391                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5392                                    (orderByComparator == null)) {
5393                            pagination = false;
5394                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST;
5395                            finderArgs = new Object[] { resourcePrimKey, status };
5396                    }
5397                    else {
5398                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST;
5399                            finderArgs = new Object[] {
5400                                            resourcePrimKey, status,
5401                                            
5402                                            start, end, orderByComparator
5403                                    };
5404                    }
5405    
5406                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
5407                                    finderArgs, this);
5408    
5409                    if ((list != null) && !list.isEmpty()) {
5410                            for (JournalArticle journalArticle : list) {
5411                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
5412                                                    (status != journalArticle.getStatus())) {
5413                                            list = null;
5414    
5415                                            break;
5416                                    }
5417                            }
5418                    }
5419    
5420                    if (list == null) {
5421                            StringBundler query = null;
5422    
5423                            if (orderByComparator != null) {
5424                                    query = new StringBundler(4 +
5425                                                    (orderByComparator.getOrderByFields().length * 3));
5426                            }
5427                            else {
5428                                    query = new StringBundler(4);
5429                            }
5430    
5431                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5432    
5433                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
5434    
5435                            query.append(_FINDER_COLUMN_R_ST_STATUS_2);
5436    
5437                            if (orderByComparator != null) {
5438                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5439                                            orderByComparator);
5440                            }
5441                            else
5442                             if (pagination) {
5443                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5444                            }
5445    
5446                            String sql = query.toString();
5447    
5448                            Session session = null;
5449    
5450                            try {
5451                                    session = openSession();
5452    
5453                                    Query q = session.createQuery(sql);
5454    
5455                                    QueryPos qPos = QueryPos.getInstance(q);
5456    
5457                                    qPos.add(resourcePrimKey);
5458    
5459                                    qPos.add(status);
5460    
5461                                    if (!pagination) {
5462                                            list = (List<JournalArticle>)QueryUtil.list(q,
5463                                                            getDialect(), start, end, false);
5464    
5465                                            Collections.sort(list);
5466    
5467                                            list = new UnmodifiableList<JournalArticle>(list);
5468                                    }
5469                                    else {
5470                                            list = (List<JournalArticle>)QueryUtil.list(q,
5471                                                            getDialect(), start, end);
5472                                    }
5473    
5474                                    cacheResult(list);
5475    
5476                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5477                            }
5478                            catch (Exception e) {
5479                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5480    
5481                                    throw processException(e);
5482                            }
5483                            finally {
5484                                    closeSession(session);
5485                            }
5486                    }
5487    
5488                    return list;
5489            }
5490    
5491            /**
5492             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
5493             *
5494             * @param resourcePrimKey the resource prim key
5495             * @param status the status
5496             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5497             * @return the first matching journal article
5498             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5499             * @throws SystemException if a system exception occurred
5500             */
5501            public JournalArticle findByR_ST_First(long resourcePrimKey, int status,
5502                    OrderByComparator orderByComparator)
5503                    throws NoSuchArticleException, SystemException {
5504                    JournalArticle journalArticle = fetchByR_ST_First(resourcePrimKey,
5505                                    status, orderByComparator);
5506    
5507                    if (journalArticle != null) {
5508                            return journalArticle;
5509                    }
5510    
5511                    StringBundler msg = new StringBundler(6);
5512    
5513                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5514    
5515                    msg.append("resourcePrimKey=");
5516                    msg.append(resourcePrimKey);
5517    
5518                    msg.append(", status=");
5519                    msg.append(status);
5520    
5521                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5522    
5523                    throw new NoSuchArticleException(msg.toString());
5524            }
5525    
5526            /**
5527             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
5528             *
5529             * @param resourcePrimKey the resource prim key
5530             * @param status the status
5531             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5532             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
5533             * @throws SystemException if a system exception occurred
5534             */
5535            public JournalArticle fetchByR_ST_First(long resourcePrimKey, int status,
5536                    OrderByComparator orderByComparator) throws SystemException {
5537                    List<JournalArticle> list = findByR_ST(resourcePrimKey, status, 0, 1,
5538                                    orderByComparator);
5539    
5540                    if (!list.isEmpty()) {
5541                            return list.get(0);
5542                    }
5543    
5544                    return null;
5545            }
5546    
5547            /**
5548             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
5549             *
5550             * @param resourcePrimKey the resource prim key
5551             * @param status the status
5552             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5553             * @return the last matching journal article
5554             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5555             * @throws SystemException if a system exception occurred
5556             */
5557            public JournalArticle findByR_ST_Last(long resourcePrimKey, int status,
5558                    OrderByComparator orderByComparator)
5559                    throws NoSuchArticleException, SystemException {
5560                    JournalArticle journalArticle = fetchByR_ST_Last(resourcePrimKey,
5561                                    status, orderByComparator);
5562    
5563                    if (journalArticle != null) {
5564                            return journalArticle;
5565                    }
5566    
5567                    StringBundler msg = new StringBundler(6);
5568    
5569                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5570    
5571                    msg.append("resourcePrimKey=");
5572                    msg.append(resourcePrimKey);
5573    
5574                    msg.append(", status=");
5575                    msg.append(status);
5576    
5577                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5578    
5579                    throw new NoSuchArticleException(msg.toString());
5580            }
5581    
5582            /**
5583             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
5584             *
5585             * @param resourcePrimKey the resource prim key
5586             * @param status the status
5587             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5588             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
5589             * @throws SystemException if a system exception occurred
5590             */
5591            public JournalArticle fetchByR_ST_Last(long resourcePrimKey, int status,
5592                    OrderByComparator orderByComparator) throws SystemException {
5593                    int count = countByR_ST(resourcePrimKey, status);
5594    
5595                    List<JournalArticle> list = findByR_ST(resourcePrimKey, status,
5596                                    count - 1, count, orderByComparator);
5597    
5598                    if (!list.isEmpty()) {
5599                            return list.get(0);
5600                    }
5601    
5602                    return null;
5603            }
5604    
5605            /**
5606             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
5607             *
5608             * @param id the primary key of the current journal article
5609             * @param resourcePrimKey the resource prim key
5610             * @param status the status
5611             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5612             * @return the previous, current, and next journal article
5613             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
5614             * @throws SystemException if a system exception occurred
5615             */
5616            public JournalArticle[] findByR_ST_PrevAndNext(long id,
5617                    long resourcePrimKey, int status, OrderByComparator orderByComparator)
5618                    throws NoSuchArticleException, SystemException {
5619                    JournalArticle journalArticle = findByPrimaryKey(id);
5620    
5621                    Session session = null;
5622    
5623                    try {
5624                            session = openSession();
5625    
5626                            JournalArticle[] array = new JournalArticleImpl[3];
5627    
5628                            array[0] = getByR_ST_PrevAndNext(session, journalArticle,
5629                                            resourcePrimKey, status, orderByComparator, true);
5630    
5631                            array[1] = journalArticle;
5632    
5633                            array[2] = getByR_ST_PrevAndNext(session, journalArticle,
5634                                            resourcePrimKey, status, orderByComparator, false);
5635    
5636                            return array;
5637                    }
5638                    catch (Exception e) {
5639                            throw processException(e);
5640                    }
5641                    finally {
5642                            closeSession(session);
5643                    }
5644            }
5645    
5646            protected JournalArticle getByR_ST_PrevAndNext(Session session,
5647                    JournalArticle journalArticle, long resourcePrimKey, int status,
5648                    OrderByComparator orderByComparator, boolean previous) {
5649                    StringBundler query = null;
5650    
5651                    if (orderByComparator != null) {
5652                            query = new StringBundler(6 +
5653                                            (orderByComparator.getOrderByFields().length * 6));
5654                    }
5655                    else {
5656                            query = new StringBundler(3);
5657                    }
5658    
5659                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5660    
5661                    query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
5662    
5663                    query.append(_FINDER_COLUMN_R_ST_STATUS_2);
5664    
5665                    if (orderByComparator != null) {
5666                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5667    
5668                            if (orderByConditionFields.length > 0) {
5669                                    query.append(WHERE_AND);
5670                            }
5671    
5672                            for (int i = 0; i < orderByConditionFields.length; i++) {
5673                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5674                                    query.append(orderByConditionFields[i]);
5675    
5676                                    if ((i + 1) < orderByConditionFields.length) {
5677                                            if (orderByComparator.isAscending() ^ previous) {
5678                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5679                                            }
5680                                            else {
5681                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5682                                            }
5683                                    }
5684                                    else {
5685                                            if (orderByComparator.isAscending() ^ previous) {
5686                                                    query.append(WHERE_GREATER_THAN);
5687                                            }
5688                                            else {
5689                                                    query.append(WHERE_LESSER_THAN);
5690                                            }
5691                                    }
5692                            }
5693    
5694                            query.append(ORDER_BY_CLAUSE);
5695    
5696                            String[] orderByFields = orderByComparator.getOrderByFields();
5697    
5698                            for (int i = 0; i < orderByFields.length; i++) {
5699                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5700                                    query.append(orderByFields[i]);
5701    
5702                                    if ((i + 1) < orderByFields.length) {
5703                                            if (orderByComparator.isAscending() ^ previous) {
5704                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5705                                            }
5706                                            else {
5707                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5708                                            }
5709                                    }
5710                                    else {
5711                                            if (orderByComparator.isAscending() ^ previous) {
5712                                                    query.append(ORDER_BY_ASC);
5713                                            }
5714                                            else {
5715                                                    query.append(ORDER_BY_DESC);
5716                                            }
5717                                    }
5718                            }
5719                    }
5720                    else {
5721                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5722                    }
5723    
5724                    String sql = query.toString();
5725    
5726                    Query q = session.createQuery(sql);
5727    
5728                    q.setFirstResult(0);
5729                    q.setMaxResults(2);
5730    
5731                    QueryPos qPos = QueryPos.getInstance(q);
5732    
5733                    qPos.add(resourcePrimKey);
5734    
5735                    qPos.add(status);
5736    
5737                    if (orderByComparator != null) {
5738                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
5739    
5740                            for (Object value : values) {
5741                                    qPos.add(value);
5742                            }
5743                    }
5744    
5745                    List<JournalArticle> list = q.list();
5746    
5747                    if (list.size() == 2) {
5748                            return list.get(1);
5749                    }
5750                    else {
5751                            return null;
5752                    }
5753            }
5754    
5755            /**
5756             * Removes all the journal articles where resourcePrimKey = &#63; and status = &#63; from the database.
5757             *
5758             * @param resourcePrimKey the resource prim key
5759             * @param status the status
5760             * @throws SystemException if a system exception occurred
5761             */
5762            public void removeByR_ST(long resourcePrimKey, int status)
5763                    throws SystemException {
5764                    for (JournalArticle journalArticle : findByR_ST(resourcePrimKey,
5765                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5766                            remove(journalArticle);
5767                    }
5768            }
5769    
5770            /**
5771             * Returns the number of journal articles where resourcePrimKey = &#63; and status = &#63;.
5772             *
5773             * @param resourcePrimKey the resource prim key
5774             * @param status the status
5775             * @return the number of matching journal articles
5776             * @throws SystemException if a system exception occurred
5777             */
5778            public int countByR_ST(long resourcePrimKey, int status)
5779                    throws SystemException {
5780                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_ST;
5781    
5782                    Object[] finderArgs = new Object[] { resourcePrimKey, status };
5783    
5784                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5785                                    this);
5786    
5787                    if (count == null) {
5788                            StringBundler query = new StringBundler(3);
5789    
5790                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
5791    
5792                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
5793    
5794                            query.append(_FINDER_COLUMN_R_ST_STATUS_2);
5795    
5796                            String sql = query.toString();
5797    
5798                            Session session = null;
5799    
5800                            try {
5801                                    session = openSession();
5802    
5803                                    Query q = session.createQuery(sql);
5804    
5805                                    QueryPos qPos = QueryPos.getInstance(q);
5806    
5807                                    qPos.add(resourcePrimKey);
5808    
5809                                    qPos.add(status);
5810    
5811                                    count = (Long)q.uniqueResult();
5812    
5813                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5814                            }
5815                            catch (Exception e) {
5816                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5817    
5818                                    throw processException(e);
5819                            }
5820                            finally {
5821                                    closeSession(session);
5822                            }
5823                    }
5824    
5825                    return count.intValue();
5826            }
5827    
5828            private static final String _FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2 = "journalArticle.resourcePrimKey = ? AND ";
5829            private static final String _FINDER_COLUMN_R_ST_STATUS_2 = "journalArticle.status = ?";
5830            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5831                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5832                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5833                            "findByG_U",
5834                            new String[] {
5835                                    Long.class.getName(), Long.class.getName(),
5836                                    
5837                            Integer.class.getName(), Integer.class.getName(),
5838                                    OrderByComparator.class.getName()
5839                            });
5840            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5841                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5842                            JournalArticleImpl.class,
5843                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U",
5844                            new String[] { Long.class.getName(), Long.class.getName() },
5845                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
5846                            JournalArticleModelImpl.USERID_COLUMN_BITMASK |
5847                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
5848                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
5849            public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5850                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
5851                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U",
5852                            new String[] { Long.class.getName(), Long.class.getName() });
5853    
5854            /**
5855             * Returns all the journal articles where groupId = &#63; and userId = &#63;.
5856             *
5857             * @param groupId the group ID
5858             * @param userId the user ID
5859             * @return the matching journal articles
5860             * @throws SystemException if a system exception occurred
5861             */
5862            public List<JournalArticle> findByG_U(long groupId, long userId)
5863                    throws SystemException {
5864                    return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
5865                            null);
5866            }
5867    
5868            /**
5869             * Returns a range of all the journal articles where groupId = &#63; and userId = &#63;.
5870             *
5871             * <p>
5872             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5873             * </p>
5874             *
5875             * @param groupId the group ID
5876             * @param userId the user ID
5877             * @param start the lower bound of the range of journal articles
5878             * @param end the upper bound of the range of journal articles (not inclusive)
5879             * @return the range of matching journal articles
5880             * @throws SystemException if a system exception occurred
5881             */
5882            public List<JournalArticle> findByG_U(long groupId, long userId, int start,
5883                    int end) throws SystemException {
5884                    return findByG_U(groupId, userId, start, end, null);
5885            }
5886    
5887            /**
5888             * Returns an ordered range of all the journal articles where groupId = &#63; and userId = &#63;.
5889             *
5890             * <p>
5891             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5892             * </p>
5893             *
5894             * @param groupId the group ID
5895             * @param userId the user ID
5896             * @param start the lower bound of the range of journal articles
5897             * @param end the upper bound of the range of journal articles (not inclusive)
5898             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5899             * @return the ordered range of matching journal articles
5900             * @throws SystemException if a system exception occurred
5901             */
5902            public List<JournalArticle> findByG_U(long groupId, long userId, int start,
5903                    int end, OrderByComparator orderByComparator) throws SystemException {
5904                    boolean pagination = true;
5905                    FinderPath finderPath = null;
5906                    Object[] finderArgs = null;
5907    
5908                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5909                                    (orderByComparator == null)) {
5910                            pagination = false;
5911                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U;
5912                            finderArgs = new Object[] { groupId, userId };
5913                    }
5914                    else {
5915                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U;
5916                            finderArgs = new Object[] {
5917                                            groupId, userId,
5918                                            
5919                                            start, end, orderByComparator
5920                                    };
5921                    }
5922    
5923                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
5924                                    finderArgs, this);
5925    
5926                    if ((list != null) && !list.isEmpty()) {
5927                            for (JournalArticle journalArticle : list) {
5928                                    if ((groupId != journalArticle.getGroupId()) ||
5929                                                    (userId != journalArticle.getUserId())) {
5930                                            list = null;
5931    
5932                                            break;
5933                                    }
5934                            }
5935                    }
5936    
5937                    if (list == null) {
5938                            StringBundler query = null;
5939    
5940                            if (orderByComparator != null) {
5941                                    query = new StringBundler(4 +
5942                                                    (orderByComparator.getOrderByFields().length * 3));
5943                            }
5944                            else {
5945                                    query = new StringBundler(4);
5946                            }
5947    
5948                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5949    
5950                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
5951    
5952                            query.append(_FINDER_COLUMN_G_U_USERID_2);
5953    
5954                            if (orderByComparator != null) {
5955                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5956                                            orderByComparator);
5957                            }
5958                            else
5959                             if (pagination) {
5960                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5961                            }
5962    
5963                            String sql = query.toString();
5964    
5965                            Session session = null;
5966    
5967                            try {
5968                                    session = openSession();
5969    
5970                                    Query q = session.createQuery(sql);
5971    
5972                                    QueryPos qPos = QueryPos.getInstance(q);
5973    
5974                                    qPos.add(groupId);
5975    
5976                                    qPos.add(userId);
5977    
5978                                    if (!pagination) {
5979                                            list = (List<JournalArticle>)QueryUtil.list(q,
5980                                                            getDialect(), start, end, false);
5981    
5982                                            Collections.sort(list);
5983    
5984                                            list = new UnmodifiableList<JournalArticle>(list);
5985                                    }
5986                                    else {
5987                                            list = (List<JournalArticle>)QueryUtil.list(q,
5988                                                            getDialect(), start, end);
5989                                    }
5990    
5991                                    cacheResult(list);
5992    
5993                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5994                            }
5995                            catch (Exception e) {
5996                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5997    
5998                                    throw processException(e);
5999                            }
6000                            finally {
6001                                    closeSession(session);
6002                            }
6003                    }
6004    
6005                    return list;
6006            }
6007    
6008            /**
6009             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63;.
6010             *
6011             * @param groupId the group ID
6012             * @param userId the user ID
6013             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6014             * @return the first matching journal article
6015             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6016             * @throws SystemException if a system exception occurred
6017             */
6018            public JournalArticle findByG_U_First(long groupId, long userId,
6019                    OrderByComparator orderByComparator)
6020                    throws NoSuchArticleException, SystemException {
6021                    JournalArticle journalArticle = fetchByG_U_First(groupId, userId,
6022                                    orderByComparator);
6023    
6024                    if (journalArticle != null) {
6025                            return journalArticle;
6026                    }
6027    
6028                    StringBundler msg = new StringBundler(6);
6029    
6030                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6031    
6032                    msg.append("groupId=");
6033                    msg.append(groupId);
6034    
6035                    msg.append(", userId=");
6036                    msg.append(userId);
6037    
6038                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6039    
6040                    throw new NoSuchArticleException(msg.toString());
6041            }
6042    
6043            /**
6044             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63;.
6045             *
6046             * @param groupId the group ID
6047             * @param userId the user ID
6048             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6049             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
6050             * @throws SystemException if a system exception occurred
6051             */
6052            public JournalArticle fetchByG_U_First(long groupId, long userId,
6053                    OrderByComparator orderByComparator) throws SystemException {
6054                    List<JournalArticle> list = findByG_U(groupId, userId, 0, 1,
6055                                    orderByComparator);
6056    
6057                    if (!list.isEmpty()) {
6058                            return list.get(0);
6059                    }
6060    
6061                    return null;
6062            }
6063    
6064            /**
6065             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63;.
6066             *
6067             * @param groupId the group ID
6068             * @param userId the user ID
6069             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6070             * @return the last matching journal article
6071             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6072             * @throws SystemException if a system exception occurred
6073             */
6074            public JournalArticle findByG_U_Last(long groupId, long userId,
6075                    OrderByComparator orderByComparator)
6076                    throws NoSuchArticleException, SystemException {
6077                    JournalArticle journalArticle = fetchByG_U_Last(groupId, userId,
6078                                    orderByComparator);
6079    
6080                    if (journalArticle != null) {
6081                            return journalArticle;
6082                    }
6083    
6084                    StringBundler msg = new StringBundler(6);
6085    
6086                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6087    
6088                    msg.append("groupId=");
6089                    msg.append(groupId);
6090    
6091                    msg.append(", userId=");
6092                    msg.append(userId);
6093    
6094                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6095    
6096                    throw new NoSuchArticleException(msg.toString());
6097            }
6098    
6099            /**
6100             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63;.
6101             *
6102             * @param groupId the group ID
6103             * @param userId the user ID
6104             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6105             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
6106             * @throws SystemException if a system exception occurred
6107             */
6108            public JournalArticle fetchByG_U_Last(long groupId, long userId,
6109                    OrderByComparator orderByComparator) throws SystemException {
6110                    int count = countByG_U(groupId, userId);
6111    
6112                    List<JournalArticle> list = findByG_U(groupId, userId, count - 1,
6113                                    count, orderByComparator);
6114    
6115                    if (!list.isEmpty()) {
6116                            return list.get(0);
6117                    }
6118    
6119                    return null;
6120            }
6121    
6122            /**
6123             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and userId = &#63;.
6124             *
6125             * @param id the primary key of the current journal article
6126             * @param groupId the group ID
6127             * @param userId the user ID
6128             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6129             * @return the previous, current, and next journal article
6130             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6131             * @throws SystemException if a system exception occurred
6132             */
6133            public JournalArticle[] findByG_U_PrevAndNext(long id, long groupId,
6134                    long userId, OrderByComparator orderByComparator)
6135                    throws NoSuchArticleException, SystemException {
6136                    JournalArticle journalArticle = findByPrimaryKey(id);
6137    
6138                    Session session = null;
6139    
6140                    try {
6141                            session = openSession();
6142    
6143                            JournalArticle[] array = new JournalArticleImpl[3];
6144    
6145                            array[0] = getByG_U_PrevAndNext(session, journalArticle, groupId,
6146                                            userId, orderByComparator, true);
6147    
6148                            array[1] = journalArticle;
6149    
6150                            array[2] = getByG_U_PrevAndNext(session, journalArticle, groupId,
6151                                            userId, orderByComparator, false);
6152    
6153                            return array;
6154                    }
6155                    catch (Exception e) {
6156                            throw processException(e);
6157                    }
6158                    finally {
6159                            closeSession(session);
6160                    }
6161            }
6162    
6163            protected JournalArticle getByG_U_PrevAndNext(Session session,
6164                    JournalArticle journalArticle, long groupId, long userId,
6165                    OrderByComparator orderByComparator, boolean previous) {
6166                    StringBundler query = null;
6167    
6168                    if (orderByComparator != null) {
6169                            query = new StringBundler(6 +
6170                                            (orderByComparator.getOrderByFields().length * 6));
6171                    }
6172                    else {
6173                            query = new StringBundler(3);
6174                    }
6175    
6176                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6177    
6178                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
6179    
6180                    query.append(_FINDER_COLUMN_G_U_USERID_2);
6181    
6182                    if (orderByComparator != null) {
6183                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6184    
6185                            if (orderByConditionFields.length > 0) {
6186                                    query.append(WHERE_AND);
6187                            }
6188    
6189                            for (int i = 0; i < orderByConditionFields.length; i++) {
6190                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6191                                    query.append(orderByConditionFields[i]);
6192    
6193                                    if ((i + 1) < orderByConditionFields.length) {
6194                                            if (orderByComparator.isAscending() ^ previous) {
6195                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6196                                            }
6197                                            else {
6198                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6199                                            }
6200                                    }
6201                                    else {
6202                                            if (orderByComparator.isAscending() ^ previous) {
6203                                                    query.append(WHERE_GREATER_THAN);
6204                                            }
6205                                            else {
6206                                                    query.append(WHERE_LESSER_THAN);
6207                                            }
6208                                    }
6209                            }
6210    
6211                            query.append(ORDER_BY_CLAUSE);
6212    
6213                            String[] orderByFields = orderByComparator.getOrderByFields();
6214    
6215                            for (int i = 0; i < orderByFields.length; i++) {
6216                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6217                                    query.append(orderByFields[i]);
6218    
6219                                    if ((i + 1) < orderByFields.length) {
6220                                            if (orderByComparator.isAscending() ^ previous) {
6221                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6222                                            }
6223                                            else {
6224                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6225                                            }
6226                                    }
6227                                    else {
6228                                            if (orderByComparator.isAscending() ^ previous) {
6229                                                    query.append(ORDER_BY_ASC);
6230                                            }
6231                                            else {
6232                                                    query.append(ORDER_BY_DESC);
6233                                            }
6234                                    }
6235                            }
6236                    }
6237                    else {
6238                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6239                    }
6240    
6241                    String sql = query.toString();
6242    
6243                    Query q = session.createQuery(sql);
6244    
6245                    q.setFirstResult(0);
6246                    q.setMaxResults(2);
6247    
6248                    QueryPos qPos = QueryPos.getInstance(q);
6249    
6250                    qPos.add(groupId);
6251    
6252                    qPos.add(userId);
6253    
6254                    if (orderByComparator != null) {
6255                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6256    
6257                            for (Object value : values) {
6258                                    qPos.add(value);
6259                            }
6260                    }
6261    
6262                    List<JournalArticle> list = q.list();
6263    
6264                    if (list.size() == 2) {
6265                            return list.get(1);
6266                    }
6267                    else {
6268                            return null;
6269                    }
6270            }
6271    
6272            /**
6273             * Returns all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
6274             *
6275             * @param groupId the group ID
6276             * @param userId the user ID
6277             * @return the matching journal articles that the user has permission to view
6278             * @throws SystemException if a system exception occurred
6279             */
6280            public List<JournalArticle> filterFindByG_U(long groupId, long userId)
6281                    throws SystemException {
6282                    return filterFindByG_U(groupId, userId, QueryUtil.ALL_POS,
6283                            QueryUtil.ALL_POS, null);
6284            }
6285    
6286            /**
6287             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
6288             *
6289             * <p>
6290             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6291             * </p>
6292             *
6293             * @param groupId the group ID
6294             * @param userId the user ID
6295             * @param start the lower bound of the range of journal articles
6296             * @param end the upper bound of the range of journal articles (not inclusive)
6297             * @return the range of matching journal articles that the user has permission to view
6298             * @throws SystemException if a system exception occurred
6299             */
6300            public List<JournalArticle> filterFindByG_U(long groupId, long userId,
6301                    int start, int end) throws SystemException {
6302                    return filterFindByG_U(groupId, userId, start, end, null);
6303            }
6304    
6305            /**
6306             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and userId = &#63;.
6307             *
6308             * <p>
6309             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6310             * </p>
6311             *
6312             * @param groupId the group ID
6313             * @param userId the user ID
6314             * @param start the lower bound of the range of journal articles
6315             * @param end the upper bound of the range of journal articles (not inclusive)
6316             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6317             * @return the ordered range of matching journal articles that the user has permission to view
6318             * @throws SystemException if a system exception occurred
6319             */
6320            public List<JournalArticle> filterFindByG_U(long groupId, long userId,
6321                    int start, int end, OrderByComparator orderByComparator)
6322                    throws SystemException {
6323                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6324                            return findByG_U(groupId, userId, start, end, orderByComparator);
6325                    }
6326    
6327                    StringBundler query = null;
6328    
6329                    if (orderByComparator != null) {
6330                            query = new StringBundler(4 +
6331                                            (orderByComparator.getOrderByFields().length * 3));
6332                    }
6333                    else {
6334                            query = new StringBundler(4);
6335                    }
6336    
6337                    if (getDB().isSupportsInlineDistinct()) {
6338                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
6339                    }
6340                    else {
6341                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
6342                    }
6343    
6344                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
6345    
6346                    query.append(_FINDER_COLUMN_G_U_USERID_2);
6347    
6348                    if (!getDB().isSupportsInlineDistinct()) {
6349                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
6350                    }
6351    
6352                    if (orderByComparator != null) {
6353                            if (getDB().isSupportsInlineDistinct()) {
6354                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6355                                            orderByComparator);
6356                            }
6357                            else {
6358                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6359                                            orderByComparator);
6360                            }
6361                    }
6362                    else {
6363                            if (getDB().isSupportsInlineDistinct()) {
6364                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6365                            }
6366                            else {
6367                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
6368                            }
6369                    }
6370    
6371                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6372                                    JournalArticle.class.getName(),
6373                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6374    
6375                    Session session = null;
6376    
6377                    try {
6378                            session = openSession();
6379    
6380                            SQLQuery q = session.createSQLQuery(sql);
6381    
6382                            if (getDB().isSupportsInlineDistinct()) {
6383                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
6384                            }
6385                            else {
6386                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
6387                            }
6388    
6389                            QueryPos qPos = QueryPos.getInstance(q);
6390    
6391                            qPos.add(groupId);
6392    
6393                            qPos.add(userId);
6394    
6395                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
6396                                    end);
6397                    }
6398                    catch (Exception e) {
6399                            throw processException(e);
6400                    }
6401                    finally {
6402                            closeSession(session);
6403                    }
6404            }
6405    
6406            /**
6407             * 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;.
6408             *
6409             * @param id the primary key of the current journal article
6410             * @param groupId the group ID
6411             * @param userId the user ID
6412             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6413             * @return the previous, current, and next journal article
6414             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6415             * @throws SystemException if a system exception occurred
6416             */
6417            public JournalArticle[] filterFindByG_U_PrevAndNext(long id, long groupId,
6418                    long userId, OrderByComparator orderByComparator)
6419                    throws NoSuchArticleException, SystemException {
6420                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6421                            return findByG_U_PrevAndNext(id, groupId, userId, orderByComparator);
6422                    }
6423    
6424                    JournalArticle journalArticle = findByPrimaryKey(id);
6425    
6426                    Session session = null;
6427    
6428                    try {
6429                            session = openSession();
6430    
6431                            JournalArticle[] array = new JournalArticleImpl[3];
6432    
6433                            array[0] = filterGetByG_U_PrevAndNext(session, journalArticle,
6434                                            groupId, userId, orderByComparator, true);
6435    
6436                            array[1] = journalArticle;
6437    
6438                            array[2] = filterGetByG_U_PrevAndNext(session, journalArticle,
6439                                            groupId, userId, orderByComparator, false);
6440    
6441                            return array;
6442                    }
6443                    catch (Exception e) {
6444                            throw processException(e);
6445                    }
6446                    finally {
6447                            closeSession(session);
6448                    }
6449            }
6450    
6451            protected JournalArticle filterGetByG_U_PrevAndNext(Session session,
6452                    JournalArticle journalArticle, long groupId, long userId,
6453                    OrderByComparator orderByComparator, boolean previous) {
6454                    StringBundler query = null;
6455    
6456                    if (orderByComparator != null) {
6457                            query = new StringBundler(6 +
6458                                            (orderByComparator.getOrderByFields().length * 6));
6459                    }
6460                    else {
6461                            query = new StringBundler(3);
6462                    }
6463    
6464                    if (getDB().isSupportsInlineDistinct()) {
6465                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
6466                    }
6467                    else {
6468                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
6469                    }
6470    
6471                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
6472    
6473                    query.append(_FINDER_COLUMN_G_U_USERID_2);
6474    
6475                    if (!getDB().isSupportsInlineDistinct()) {
6476                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
6477                    }
6478    
6479                    if (orderByComparator != null) {
6480                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6481    
6482                            if (orderByConditionFields.length > 0) {
6483                                    query.append(WHERE_AND);
6484                            }
6485    
6486                            for (int i = 0; i < orderByConditionFields.length; i++) {
6487                                    if (getDB().isSupportsInlineDistinct()) {
6488                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6489                                    }
6490                                    else {
6491                                            query.append(_ORDER_BY_ENTITY_TABLE);
6492                                    }
6493    
6494                                    query.append(orderByConditionFields[i]);
6495    
6496                                    if ((i + 1) < orderByConditionFields.length) {
6497                                            if (orderByComparator.isAscending() ^ previous) {
6498                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6499                                            }
6500                                            else {
6501                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6502                                            }
6503                                    }
6504                                    else {
6505                                            if (orderByComparator.isAscending() ^ previous) {
6506                                                    query.append(WHERE_GREATER_THAN);
6507                                            }
6508                                            else {
6509                                                    query.append(WHERE_LESSER_THAN);
6510                                            }
6511                                    }
6512                            }
6513    
6514                            query.append(ORDER_BY_CLAUSE);
6515    
6516                            String[] orderByFields = orderByComparator.getOrderByFields();
6517    
6518                            for (int i = 0; i < orderByFields.length; i++) {
6519                                    if (getDB().isSupportsInlineDistinct()) {
6520                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6521                                    }
6522                                    else {
6523                                            query.append(_ORDER_BY_ENTITY_TABLE);
6524                                    }
6525    
6526                                    query.append(orderByFields[i]);
6527    
6528                                    if ((i + 1) < orderByFields.length) {
6529                                            if (orderByComparator.isAscending() ^ previous) {
6530                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6531                                            }
6532                                            else {
6533                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6534                                            }
6535                                    }
6536                                    else {
6537                                            if (orderByComparator.isAscending() ^ previous) {
6538                                                    query.append(ORDER_BY_ASC);
6539                                            }
6540                                            else {
6541                                                    query.append(ORDER_BY_DESC);
6542                                            }
6543                                    }
6544                            }
6545                    }
6546                    else {
6547                            if (getDB().isSupportsInlineDistinct()) {
6548                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6549                            }
6550                            else {
6551                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
6552                            }
6553                    }
6554    
6555                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6556                                    JournalArticle.class.getName(),
6557                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6558    
6559                    SQLQuery q = session.createSQLQuery(sql);
6560    
6561                    q.setFirstResult(0);
6562                    q.setMaxResults(2);
6563    
6564                    if (getDB().isSupportsInlineDistinct()) {
6565                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
6566                    }
6567                    else {
6568                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
6569                    }
6570    
6571                    QueryPos qPos = QueryPos.getInstance(q);
6572    
6573                    qPos.add(groupId);
6574    
6575                    qPos.add(userId);
6576    
6577                    if (orderByComparator != null) {
6578                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6579    
6580                            for (Object value : values) {
6581                                    qPos.add(value);
6582                            }
6583                    }
6584    
6585                    List<JournalArticle> list = q.list();
6586    
6587                    if (list.size() == 2) {
6588                            return list.get(1);
6589                    }
6590                    else {
6591                            return null;
6592                    }
6593            }
6594    
6595            /**
6596             * Removes all the journal articles where groupId = &#63; and userId = &#63; from the database.
6597             *
6598             * @param groupId the group ID
6599             * @param userId the user ID
6600             * @throws SystemException if a system exception occurred
6601             */
6602            public void removeByG_U(long groupId, long userId)
6603                    throws SystemException {
6604                    for (JournalArticle journalArticle : findByG_U(groupId, userId,
6605                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6606                            remove(journalArticle);
6607                    }
6608            }
6609    
6610            /**
6611             * Returns the number of journal articles where groupId = &#63; and userId = &#63;.
6612             *
6613             * @param groupId the group ID
6614             * @param userId the user ID
6615             * @return the number of matching journal articles
6616             * @throws SystemException if a system exception occurred
6617             */
6618            public int countByG_U(long groupId, long userId) throws SystemException {
6619                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U;
6620    
6621                    Object[] finderArgs = new Object[] { groupId, userId };
6622    
6623                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6624                                    this);
6625    
6626                    if (count == null) {
6627                            StringBundler query = new StringBundler(3);
6628    
6629                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
6630    
6631                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
6632    
6633                            query.append(_FINDER_COLUMN_G_U_USERID_2);
6634    
6635                            String sql = query.toString();
6636    
6637                            Session session = null;
6638    
6639                            try {
6640                                    session = openSession();
6641    
6642                                    Query q = session.createQuery(sql);
6643    
6644                                    QueryPos qPos = QueryPos.getInstance(q);
6645    
6646                                    qPos.add(groupId);
6647    
6648                                    qPos.add(userId);
6649    
6650                                    count = (Long)q.uniqueResult();
6651    
6652                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6653                            }
6654                            catch (Exception e) {
6655                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6656    
6657                                    throw processException(e);
6658                            }
6659                            finally {
6660                                    closeSession(session);
6661                            }
6662                    }
6663    
6664                    return count.intValue();
6665            }
6666    
6667            /**
6668             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
6669             *
6670             * @param groupId the group ID
6671             * @param userId the user ID
6672             * @return the number of matching journal articles that the user has permission to view
6673             * @throws SystemException if a system exception occurred
6674             */
6675            public int filterCountByG_U(long groupId, long userId)
6676                    throws SystemException {
6677                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6678                            return countByG_U(groupId, userId);
6679                    }
6680    
6681                    StringBundler query = new StringBundler(3);
6682    
6683                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
6684    
6685                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
6686    
6687                    query.append(_FINDER_COLUMN_G_U_USERID_2);
6688    
6689                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6690                                    JournalArticle.class.getName(),
6691                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6692    
6693                    Session session = null;
6694    
6695                    try {
6696                            session = openSession();
6697    
6698                            SQLQuery q = session.createSQLQuery(sql);
6699    
6700                            q.addScalar(COUNT_COLUMN_NAME,
6701                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
6702    
6703                            QueryPos qPos = QueryPos.getInstance(q);
6704    
6705                            qPos.add(groupId);
6706    
6707                            qPos.add(userId);
6708    
6709                            Long count = (Long)q.uniqueResult();
6710    
6711                            return count.intValue();
6712                    }
6713                    catch (Exception e) {
6714                            throw processException(e);
6715                    }
6716                    finally {
6717                            closeSession(session);
6718                    }
6719            }
6720    
6721            private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "journalArticle.groupId = ? AND ";
6722            private static final String _FINDER_COLUMN_G_U_USERID_2 = "journalArticle.userId = ?";
6723            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6724                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
6725                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
6726                            "findByG_F",
6727                            new String[] {
6728                                    Long.class.getName(), Long.class.getName(),
6729                                    
6730                            Integer.class.getName(), Integer.class.getName(),
6731                                    OrderByComparator.class.getName()
6732                            });
6733            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6734                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
6735                            JournalArticleImpl.class,
6736                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F",
6737                            new String[] { Long.class.getName(), Long.class.getName() },
6738                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
6739                            JournalArticleModelImpl.FOLDERID_COLUMN_BITMASK |
6740                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
6741                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
6742            public static final FinderPath FINDER_PATH_COUNT_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6743                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
6744                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F",
6745                            new String[] { Long.class.getName(), Long.class.getName() });
6746            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6747                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
6748                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F",
6749                            new String[] { Long.class.getName(), Long.class.getName() });
6750    
6751            /**
6752             * Returns all the journal articles where groupId = &#63; and folderId = &#63;.
6753             *
6754             * @param groupId the group ID
6755             * @param folderId the folder ID
6756             * @return the matching journal articles
6757             * @throws SystemException if a system exception occurred
6758             */
6759            public List<JournalArticle> findByG_F(long groupId, long folderId)
6760                    throws SystemException {
6761                    return findByG_F(groupId, folderId, QueryUtil.ALL_POS,
6762                            QueryUtil.ALL_POS, null);
6763            }
6764    
6765            /**
6766             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63;.
6767             *
6768             * <p>
6769             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6770             * </p>
6771             *
6772             * @param groupId the group ID
6773             * @param folderId the folder ID
6774             * @param start the lower bound of the range of journal articles
6775             * @param end the upper bound of the range of journal articles (not inclusive)
6776             * @return the range of matching journal articles
6777             * @throws SystemException if a system exception occurred
6778             */
6779            public List<JournalArticle> findByG_F(long groupId, long folderId,
6780                    int start, int end) throws SystemException {
6781                    return findByG_F(groupId, folderId, start, end, null);
6782            }
6783    
6784            /**
6785             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63;.
6786             *
6787             * <p>
6788             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6789             * </p>
6790             *
6791             * @param groupId the group ID
6792             * @param folderId the folder ID
6793             * @param start the lower bound of the range of journal articles
6794             * @param end the upper bound of the range of journal articles (not inclusive)
6795             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6796             * @return the ordered range of matching journal articles
6797             * @throws SystemException if a system exception occurred
6798             */
6799            public List<JournalArticle> findByG_F(long groupId, long folderId,
6800                    int start, int end, OrderByComparator orderByComparator)
6801                    throws SystemException {
6802                    boolean pagination = true;
6803                    FinderPath finderPath = null;
6804                    Object[] finderArgs = null;
6805    
6806                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6807                                    (orderByComparator == null)) {
6808                            pagination = false;
6809                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F;
6810                            finderArgs = new Object[] { groupId, folderId };
6811                    }
6812                    else {
6813                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F;
6814                            finderArgs = new Object[] {
6815                                            groupId, folderId,
6816                                            
6817                                            start, end, orderByComparator
6818                                    };
6819                    }
6820    
6821                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
6822                                    finderArgs, this);
6823    
6824                    if ((list != null) && !list.isEmpty()) {
6825                            for (JournalArticle journalArticle : list) {
6826                                    if ((groupId != journalArticle.getGroupId()) ||
6827                                                    (folderId != journalArticle.getFolderId())) {
6828                                            list = null;
6829    
6830                                            break;
6831                                    }
6832                            }
6833                    }
6834    
6835                    if (list == null) {
6836                            StringBundler query = null;
6837    
6838                            if (orderByComparator != null) {
6839                                    query = new StringBundler(4 +
6840                                                    (orderByComparator.getOrderByFields().length * 3));
6841                            }
6842                            else {
6843                                    query = new StringBundler(4);
6844                            }
6845    
6846                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6847    
6848                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
6849    
6850                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
6851    
6852                            if (orderByComparator != null) {
6853                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6854                                            orderByComparator);
6855                            }
6856                            else
6857                             if (pagination) {
6858                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6859                            }
6860    
6861                            String sql = query.toString();
6862    
6863                            Session session = null;
6864    
6865                            try {
6866                                    session = openSession();
6867    
6868                                    Query q = session.createQuery(sql);
6869    
6870                                    QueryPos qPos = QueryPos.getInstance(q);
6871    
6872                                    qPos.add(groupId);
6873    
6874                                    qPos.add(folderId);
6875    
6876                                    if (!pagination) {
6877                                            list = (List<JournalArticle>)QueryUtil.list(q,
6878                                                            getDialect(), start, end, false);
6879    
6880                                            Collections.sort(list);
6881    
6882                                            list = new UnmodifiableList<JournalArticle>(list);
6883                                    }
6884                                    else {
6885                                            list = (List<JournalArticle>)QueryUtil.list(q,
6886                                                            getDialect(), start, end);
6887                                    }
6888    
6889                                    cacheResult(list);
6890    
6891                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6892                            }
6893                            catch (Exception e) {
6894                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6895    
6896                                    throw processException(e);
6897                            }
6898                            finally {
6899                                    closeSession(session);
6900                            }
6901                    }
6902    
6903                    return list;
6904            }
6905    
6906            /**
6907             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63;.
6908             *
6909             * @param groupId the group ID
6910             * @param folderId the folder ID
6911             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6912             * @return the first matching journal article
6913             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6914             * @throws SystemException if a system exception occurred
6915             */
6916            public JournalArticle findByG_F_First(long groupId, long folderId,
6917                    OrderByComparator orderByComparator)
6918                    throws NoSuchArticleException, SystemException {
6919                    JournalArticle journalArticle = fetchByG_F_First(groupId, folderId,
6920                                    orderByComparator);
6921    
6922                    if (journalArticle != null) {
6923                            return journalArticle;
6924                    }
6925    
6926                    StringBundler msg = new StringBundler(6);
6927    
6928                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6929    
6930                    msg.append("groupId=");
6931                    msg.append(groupId);
6932    
6933                    msg.append(", folderId=");
6934                    msg.append(folderId);
6935    
6936                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6937    
6938                    throw new NoSuchArticleException(msg.toString());
6939            }
6940    
6941            /**
6942             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63;.
6943             *
6944             * @param groupId the group ID
6945             * @param folderId the folder ID
6946             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6947             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
6948             * @throws SystemException if a system exception occurred
6949             */
6950            public JournalArticle fetchByG_F_First(long groupId, long folderId,
6951                    OrderByComparator orderByComparator) throws SystemException {
6952                    List<JournalArticle> list = findByG_F(groupId, folderId, 0, 1,
6953                                    orderByComparator);
6954    
6955                    if (!list.isEmpty()) {
6956                            return list.get(0);
6957                    }
6958    
6959                    return null;
6960            }
6961    
6962            /**
6963             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63;.
6964             *
6965             * @param groupId the group ID
6966             * @param folderId the folder ID
6967             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6968             * @return the last matching journal article
6969             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6970             * @throws SystemException if a system exception occurred
6971             */
6972            public JournalArticle findByG_F_Last(long groupId, long folderId,
6973                    OrderByComparator orderByComparator)
6974                    throws NoSuchArticleException, SystemException {
6975                    JournalArticle journalArticle = fetchByG_F_Last(groupId, folderId,
6976                                    orderByComparator);
6977    
6978                    if (journalArticle != null) {
6979                            return journalArticle;
6980                    }
6981    
6982                    StringBundler msg = new StringBundler(6);
6983    
6984                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6985    
6986                    msg.append("groupId=");
6987                    msg.append(groupId);
6988    
6989                    msg.append(", folderId=");
6990                    msg.append(folderId);
6991    
6992                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6993    
6994                    throw new NoSuchArticleException(msg.toString());
6995            }
6996    
6997            /**
6998             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63;.
6999             *
7000             * @param groupId the group ID
7001             * @param folderId the folder ID
7002             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7003             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
7004             * @throws SystemException if a system exception occurred
7005             */
7006            public JournalArticle fetchByG_F_Last(long groupId, long folderId,
7007                    OrderByComparator orderByComparator) throws SystemException {
7008                    int count = countByG_F(groupId, folderId);
7009    
7010                    List<JournalArticle> list = findByG_F(groupId, folderId, count - 1,
7011                                    count, orderByComparator);
7012    
7013                    if (!list.isEmpty()) {
7014                            return list.get(0);
7015                    }
7016    
7017                    return null;
7018            }
7019    
7020            /**
7021             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and folderId = &#63;.
7022             *
7023             * @param id the primary key of the current journal article
7024             * @param groupId the group ID
7025             * @param folderId the folder ID
7026             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7027             * @return the previous, current, and next journal article
7028             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
7029             * @throws SystemException if a system exception occurred
7030             */
7031            public JournalArticle[] findByG_F_PrevAndNext(long id, long groupId,
7032                    long folderId, OrderByComparator orderByComparator)
7033                    throws NoSuchArticleException, SystemException {
7034                    JournalArticle journalArticle = findByPrimaryKey(id);
7035    
7036                    Session session = null;
7037    
7038                    try {
7039                            session = openSession();
7040    
7041                            JournalArticle[] array = new JournalArticleImpl[3];
7042    
7043                            array[0] = getByG_F_PrevAndNext(session, journalArticle, groupId,
7044                                            folderId, orderByComparator, true);
7045    
7046                            array[1] = journalArticle;
7047    
7048                            array[2] = getByG_F_PrevAndNext(session, journalArticle, groupId,
7049                                            folderId, orderByComparator, false);
7050    
7051                            return array;
7052                    }
7053                    catch (Exception e) {
7054                            throw processException(e);
7055                    }
7056                    finally {
7057                            closeSession(session);
7058                    }
7059            }
7060    
7061            protected JournalArticle getByG_F_PrevAndNext(Session session,
7062                    JournalArticle journalArticle, long groupId, long folderId,
7063                    OrderByComparator orderByComparator, boolean previous) {
7064                    StringBundler query = null;
7065    
7066                    if (orderByComparator != null) {
7067                            query = new StringBundler(6 +
7068                                            (orderByComparator.getOrderByFields().length * 6));
7069                    }
7070                    else {
7071                            query = new StringBundler(3);
7072                    }
7073    
7074                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7075    
7076                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
7077    
7078                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
7079    
7080                    if (orderByComparator != null) {
7081                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7082    
7083                            if (orderByConditionFields.length > 0) {
7084                                    query.append(WHERE_AND);
7085                            }
7086    
7087                            for (int i = 0; i < orderByConditionFields.length; i++) {
7088                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7089                                    query.append(orderByConditionFields[i]);
7090    
7091                                    if ((i + 1) < orderByConditionFields.length) {
7092                                            if (orderByComparator.isAscending() ^ previous) {
7093                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7094                                            }
7095                                            else {
7096                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7097                                            }
7098                                    }
7099                                    else {
7100                                            if (orderByComparator.isAscending() ^ previous) {
7101                                                    query.append(WHERE_GREATER_THAN);
7102                                            }
7103                                            else {
7104                                                    query.append(WHERE_LESSER_THAN);
7105                                            }
7106                                    }
7107                            }
7108    
7109                            query.append(ORDER_BY_CLAUSE);
7110    
7111                            String[] orderByFields = orderByComparator.getOrderByFields();
7112    
7113                            for (int i = 0; i < orderByFields.length; i++) {
7114                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7115                                    query.append(orderByFields[i]);
7116    
7117                                    if ((i + 1) < orderByFields.length) {
7118                                            if (orderByComparator.isAscending() ^ previous) {
7119                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7120                                            }
7121                                            else {
7122                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7123                                            }
7124                                    }
7125                                    else {
7126                                            if (orderByComparator.isAscending() ^ previous) {
7127                                                    query.append(ORDER_BY_ASC);
7128                                            }
7129                                            else {
7130                                                    query.append(ORDER_BY_DESC);
7131                                            }
7132                                    }
7133                            }
7134                    }
7135                    else {
7136                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7137                    }
7138    
7139                    String sql = query.toString();
7140    
7141                    Query q = session.createQuery(sql);
7142    
7143                    q.setFirstResult(0);
7144                    q.setMaxResults(2);
7145    
7146                    QueryPos qPos = QueryPos.getInstance(q);
7147    
7148                    qPos.add(groupId);
7149    
7150                    qPos.add(folderId);
7151    
7152                    if (orderByComparator != null) {
7153                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7154    
7155                            for (Object value : values) {
7156                                    qPos.add(value);
7157                            }
7158                    }
7159    
7160                    List<JournalArticle> list = q.list();
7161    
7162                    if (list.size() == 2) {
7163                            return list.get(1);
7164                    }
7165                    else {
7166                            return null;
7167                    }
7168            }
7169    
7170            /**
7171             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
7172             *
7173             * @param groupId the group ID
7174             * @param folderId the folder ID
7175             * @return the matching journal articles that the user has permission to view
7176             * @throws SystemException if a system exception occurred
7177             */
7178            public List<JournalArticle> filterFindByG_F(long groupId, long folderId)
7179                    throws SystemException {
7180                    return filterFindByG_F(groupId, folderId, QueryUtil.ALL_POS,
7181                            QueryUtil.ALL_POS, null);
7182            }
7183    
7184            /**
7185             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
7186             *
7187             * <p>
7188             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7189             * </p>
7190             *
7191             * @param groupId the group ID
7192             * @param folderId the folder ID
7193             * @param start the lower bound of the range of journal articles
7194             * @param end the upper bound of the range of journal articles (not inclusive)
7195             * @return the range of matching journal articles that the user has permission to view
7196             * @throws SystemException if a system exception occurred
7197             */
7198            public List<JournalArticle> filterFindByG_F(long groupId, long folderId,
7199                    int start, int end) throws SystemException {
7200                    return filterFindByG_F(groupId, folderId, start, end, null);
7201            }
7202    
7203            /**
7204             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and folderId = &#63;.
7205             *
7206             * <p>
7207             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7208             * </p>
7209             *
7210             * @param groupId the group ID
7211             * @param folderId the folder ID
7212             * @param start the lower bound of the range of journal articles
7213             * @param end the upper bound of the range of journal articles (not inclusive)
7214             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7215             * @return the ordered range of matching journal articles that the user has permission to view
7216             * @throws SystemException if a system exception occurred
7217             */
7218            public List<JournalArticle> filterFindByG_F(long groupId, long folderId,
7219                    int start, int end, OrderByComparator orderByComparator)
7220                    throws SystemException {
7221                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7222                            return findByG_F(groupId, folderId, start, end, orderByComparator);
7223                    }
7224    
7225                    StringBundler query = null;
7226    
7227                    if (orderByComparator != null) {
7228                            query = new StringBundler(4 +
7229                                            (orderByComparator.getOrderByFields().length * 3));
7230                    }
7231                    else {
7232                            query = new StringBundler(4);
7233                    }
7234    
7235                    if (getDB().isSupportsInlineDistinct()) {
7236                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7237                    }
7238                    else {
7239                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7240                    }
7241    
7242                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
7243    
7244                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
7245    
7246                    if (!getDB().isSupportsInlineDistinct()) {
7247                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7248                    }
7249    
7250                    if (orderByComparator != null) {
7251                            if (getDB().isSupportsInlineDistinct()) {
7252                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7253                                            orderByComparator);
7254                            }
7255                            else {
7256                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7257                                            orderByComparator);
7258                            }
7259                    }
7260                    else {
7261                            if (getDB().isSupportsInlineDistinct()) {
7262                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7263                            }
7264                            else {
7265                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7266                            }
7267                    }
7268    
7269                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7270                                    JournalArticle.class.getName(),
7271                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7272    
7273                    Session session = null;
7274    
7275                    try {
7276                            session = openSession();
7277    
7278                            SQLQuery q = session.createSQLQuery(sql);
7279    
7280                            if (getDB().isSupportsInlineDistinct()) {
7281                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7282                            }
7283                            else {
7284                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7285                            }
7286    
7287                            QueryPos qPos = QueryPos.getInstance(q);
7288    
7289                            qPos.add(groupId);
7290    
7291                            qPos.add(folderId);
7292    
7293                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
7294                                    end);
7295                    }
7296                    catch (Exception e) {
7297                            throw processException(e);
7298                    }
7299                    finally {
7300                            closeSession(session);
7301                    }
7302            }
7303    
7304            /**
7305             * 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;.
7306             *
7307             * @param id the primary key of the current journal article
7308             * @param groupId the group ID
7309             * @param folderId the folder ID
7310             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7311             * @return the previous, current, and next journal article
7312             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
7313             * @throws SystemException if a system exception occurred
7314             */
7315            public JournalArticle[] filterFindByG_F_PrevAndNext(long id, long groupId,
7316                    long folderId, OrderByComparator orderByComparator)
7317                    throws NoSuchArticleException, SystemException {
7318                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7319                            return findByG_F_PrevAndNext(id, groupId, folderId,
7320                                    orderByComparator);
7321                    }
7322    
7323                    JournalArticle journalArticle = findByPrimaryKey(id);
7324    
7325                    Session session = null;
7326    
7327                    try {
7328                            session = openSession();
7329    
7330                            JournalArticle[] array = new JournalArticleImpl[3];
7331    
7332                            array[0] = filterGetByG_F_PrevAndNext(session, journalArticle,
7333                                            groupId, folderId, orderByComparator, true);
7334    
7335                            array[1] = journalArticle;
7336    
7337                            array[2] = filterGetByG_F_PrevAndNext(session, journalArticle,
7338                                            groupId, folderId, orderByComparator, false);
7339    
7340                            return array;
7341                    }
7342                    catch (Exception e) {
7343                            throw processException(e);
7344                    }
7345                    finally {
7346                            closeSession(session);
7347                    }
7348            }
7349    
7350            protected JournalArticle filterGetByG_F_PrevAndNext(Session session,
7351                    JournalArticle journalArticle, long groupId, long folderId,
7352                    OrderByComparator orderByComparator, boolean previous) {
7353                    StringBundler query = null;
7354    
7355                    if (orderByComparator != null) {
7356                            query = new StringBundler(6 +
7357                                            (orderByComparator.getOrderByFields().length * 6));
7358                    }
7359                    else {
7360                            query = new StringBundler(3);
7361                    }
7362    
7363                    if (getDB().isSupportsInlineDistinct()) {
7364                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7365                    }
7366                    else {
7367                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7368                    }
7369    
7370                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
7371    
7372                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
7373    
7374                    if (!getDB().isSupportsInlineDistinct()) {
7375                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7376                    }
7377    
7378                    if (orderByComparator != null) {
7379                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7380    
7381                            if (orderByConditionFields.length > 0) {
7382                                    query.append(WHERE_AND);
7383                            }
7384    
7385                            for (int i = 0; i < orderByConditionFields.length; i++) {
7386                                    if (getDB().isSupportsInlineDistinct()) {
7387                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7388                                    }
7389                                    else {
7390                                            query.append(_ORDER_BY_ENTITY_TABLE);
7391                                    }
7392    
7393                                    query.append(orderByConditionFields[i]);
7394    
7395                                    if ((i + 1) < orderByConditionFields.length) {
7396                                            if (orderByComparator.isAscending() ^ previous) {
7397                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7398                                            }
7399                                            else {
7400                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7401                                            }
7402                                    }
7403                                    else {
7404                                            if (orderByComparator.isAscending() ^ previous) {
7405                                                    query.append(WHERE_GREATER_THAN);
7406                                            }
7407                                            else {
7408                                                    query.append(WHERE_LESSER_THAN);
7409                                            }
7410                                    }
7411                            }
7412    
7413                            query.append(ORDER_BY_CLAUSE);
7414    
7415                            String[] orderByFields = orderByComparator.getOrderByFields();
7416    
7417                            for (int i = 0; i < orderByFields.length; i++) {
7418                                    if (getDB().isSupportsInlineDistinct()) {
7419                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7420                                    }
7421                                    else {
7422                                            query.append(_ORDER_BY_ENTITY_TABLE);
7423                                    }
7424    
7425                                    query.append(orderByFields[i]);
7426    
7427                                    if ((i + 1) < orderByFields.length) {
7428                                            if (orderByComparator.isAscending() ^ previous) {
7429                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7430                                            }
7431                                            else {
7432                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7433                                            }
7434                                    }
7435                                    else {
7436                                            if (orderByComparator.isAscending() ^ previous) {
7437                                                    query.append(ORDER_BY_ASC);
7438                                            }
7439                                            else {
7440                                                    query.append(ORDER_BY_DESC);
7441                                            }
7442                                    }
7443                            }
7444                    }
7445                    else {
7446                            if (getDB().isSupportsInlineDistinct()) {
7447                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7448                            }
7449                            else {
7450                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7451                            }
7452                    }
7453    
7454                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7455                                    JournalArticle.class.getName(),
7456                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7457    
7458                    SQLQuery q = session.createSQLQuery(sql);
7459    
7460                    q.setFirstResult(0);
7461                    q.setMaxResults(2);
7462    
7463                    if (getDB().isSupportsInlineDistinct()) {
7464                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7465                    }
7466                    else {
7467                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7468                    }
7469    
7470                    QueryPos qPos = QueryPos.getInstance(q);
7471    
7472                    qPos.add(groupId);
7473    
7474                    qPos.add(folderId);
7475    
7476                    if (orderByComparator != null) {
7477                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7478    
7479                            for (Object value : values) {
7480                                    qPos.add(value);
7481                            }
7482                    }
7483    
7484                    List<JournalArticle> list = q.list();
7485    
7486                    if (list.size() == 2) {
7487                            return list.get(1);
7488                    }
7489                    else {
7490                            return null;
7491                    }
7492            }
7493    
7494            /**
7495             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
7496             *
7497             * @param groupId the group ID
7498             * @param folderIds the folder IDs
7499             * @return the matching journal articles that the user has permission to view
7500             * @throws SystemException if a system exception occurred
7501             */
7502            public List<JournalArticle> filterFindByG_F(long groupId, long[] folderIds)
7503                    throws SystemException {
7504                    return filterFindByG_F(groupId, folderIds, QueryUtil.ALL_POS,
7505                            QueryUtil.ALL_POS, null);
7506            }
7507    
7508            /**
7509             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
7510             *
7511             * <p>
7512             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7513             * </p>
7514             *
7515             * @param groupId the group ID
7516             * @param folderIds the folder IDs
7517             * @param start the lower bound of the range of journal articles
7518             * @param end the upper bound of the range of journal articles (not inclusive)
7519             * @return the range of matching journal articles that the user has permission to view
7520             * @throws SystemException if a system exception occurred
7521             */
7522            public List<JournalArticle> filterFindByG_F(long groupId, long[] folderIds,
7523                    int start, int end) throws SystemException {
7524                    return filterFindByG_F(groupId, folderIds, start, end, null);
7525            }
7526    
7527            /**
7528             * Returns an ordered range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
7529             *
7530             * <p>
7531             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7532             * </p>
7533             *
7534             * @param groupId the group ID
7535             * @param folderIds the folder IDs
7536             * @param start the lower bound of the range of journal articles
7537             * @param end the upper bound of the range of journal articles (not inclusive)
7538             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7539             * @return the ordered range of matching journal articles that the user has permission to view
7540             * @throws SystemException if a system exception occurred
7541             */
7542            public List<JournalArticle> filterFindByG_F(long groupId, long[] folderIds,
7543                    int start, int end, OrderByComparator orderByComparator)
7544                    throws SystemException {
7545                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7546                            return findByG_F(groupId, folderIds, start, end, orderByComparator);
7547                    }
7548    
7549                    StringBundler query = new StringBundler();
7550    
7551                    if (getDB().isSupportsInlineDistinct()) {
7552                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7553                    }
7554                    else {
7555                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7556                    }
7557    
7558                    boolean conjunctionable = false;
7559    
7560                    if (conjunctionable) {
7561                            query.append(WHERE_AND);
7562                    }
7563    
7564                    query.append(_FINDER_COLUMN_G_F_GROUPID_5);
7565    
7566                    conjunctionable = true;
7567    
7568                    if ((folderIds == null) || (folderIds.length > 0)) {
7569                            if (conjunctionable) {
7570                                    query.append(WHERE_AND);
7571                            }
7572    
7573                            query.append(StringPool.OPEN_PARENTHESIS);
7574    
7575                            for (int i = 0; i < folderIds.length; i++) {
7576                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
7577    
7578                                    if ((i + 1) < folderIds.length) {
7579                                            query.append(WHERE_OR);
7580                                    }
7581                            }
7582    
7583                            query.append(StringPool.CLOSE_PARENTHESIS);
7584    
7585                            conjunctionable = true;
7586                    }
7587    
7588                    if (!getDB().isSupportsInlineDistinct()) {
7589                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7590                    }
7591    
7592                    if (orderByComparator != null) {
7593                            if (getDB().isSupportsInlineDistinct()) {
7594                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7595                                            orderByComparator);
7596                            }
7597                            else {
7598                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7599                                            orderByComparator);
7600                            }
7601                    }
7602                    else {
7603                            if (getDB().isSupportsInlineDistinct()) {
7604                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7605                            }
7606                            else {
7607                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7608                            }
7609                    }
7610    
7611                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7612                                    JournalArticle.class.getName(),
7613                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7614    
7615                    Session session = null;
7616    
7617                    try {
7618                            session = openSession();
7619    
7620                            SQLQuery q = session.createSQLQuery(sql);
7621    
7622                            if (getDB().isSupportsInlineDistinct()) {
7623                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7624                            }
7625                            else {
7626                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7627                            }
7628    
7629                            QueryPos qPos = QueryPos.getInstance(q);
7630    
7631                            qPos.add(groupId);
7632    
7633                            if (folderIds != null) {
7634                                    qPos.add(folderIds);
7635                            }
7636    
7637                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
7638                                    end);
7639                    }
7640                    catch (Exception e) {
7641                            throw processException(e);
7642                    }
7643                    finally {
7644                            closeSession(session);
7645                    }
7646            }
7647    
7648            /**
7649             * Returns all the journal articles where groupId = &#63; and folderId = any &#63;.
7650             *
7651             * <p>
7652             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7653             * </p>
7654             *
7655             * @param groupId the group ID
7656             * @param folderIds the folder IDs
7657             * @return the matching journal articles
7658             * @throws SystemException if a system exception occurred
7659             */
7660            public List<JournalArticle> findByG_F(long groupId, long[] folderIds)
7661                    throws SystemException {
7662                    return findByG_F(groupId, folderIds, QueryUtil.ALL_POS,
7663                            QueryUtil.ALL_POS, null);
7664            }
7665    
7666            /**
7667             * Returns a range of all the journal articles where groupId = &#63; and folderId = any &#63;.
7668             *
7669             * <p>
7670             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7671             * </p>
7672             *
7673             * @param groupId the group ID
7674             * @param folderIds the folder IDs
7675             * @param start the lower bound of the range of journal articles
7676             * @param end the upper bound of the range of journal articles (not inclusive)
7677             * @return the range of matching journal articles
7678             * @throws SystemException if a system exception occurred
7679             */
7680            public List<JournalArticle> findByG_F(long groupId, long[] folderIds,
7681                    int start, int end) throws SystemException {
7682                    return findByG_F(groupId, folderIds, start, end, null);
7683            }
7684    
7685            /**
7686             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = any &#63;.
7687             *
7688             * <p>
7689             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7690             * </p>
7691             *
7692             * @param groupId the group ID
7693             * @param folderIds the folder IDs
7694             * @param start the lower bound of the range of journal articles
7695             * @param end the upper bound of the range of journal articles (not inclusive)
7696             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7697             * @return the ordered range of matching journal articles
7698             * @throws SystemException if a system exception occurred
7699             */
7700            public List<JournalArticle> findByG_F(long groupId, long[] folderIds,
7701                    int start, int end, OrderByComparator orderByComparator)
7702                    throws SystemException {
7703                    if ((folderIds != null) && (folderIds.length == 1)) {
7704                            return findByG_F(groupId, folderIds[0], start, end,
7705                                    orderByComparator);
7706                    }
7707    
7708                    boolean pagination = true;
7709                    Object[] finderArgs = null;
7710    
7711                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7712                                    (orderByComparator == null)) {
7713                            pagination = false;
7714                            finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
7715                    }
7716                    else {
7717                            finderArgs = new Object[] {
7718                                            groupId, StringUtil.merge(folderIds),
7719                                            
7720                                            start, end, orderByComparator
7721                                    };
7722                    }
7723    
7724                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
7725                                    finderArgs, this);
7726    
7727                    if ((list != null) && !list.isEmpty()) {
7728                            for (JournalArticle journalArticle : list) {
7729                                    if ((groupId != journalArticle.getGroupId()) ||
7730                                                    !ArrayUtil.contains(folderIds,
7731                                                            journalArticle.getFolderId())) {
7732                                            list = null;
7733    
7734                                            break;
7735                                    }
7736                            }
7737                    }
7738    
7739                    if (list == null) {
7740                            StringBundler query = new StringBundler();
7741    
7742                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7743    
7744                            boolean conjunctionable = false;
7745    
7746                            if (conjunctionable) {
7747                                    query.append(WHERE_AND);
7748                            }
7749    
7750                            query.append(_FINDER_COLUMN_G_F_GROUPID_5);
7751    
7752                            conjunctionable = true;
7753    
7754                            if ((folderIds == null) || (folderIds.length > 0)) {
7755                                    if (conjunctionable) {
7756                                            query.append(WHERE_AND);
7757                                    }
7758    
7759                                    query.append(StringPool.OPEN_PARENTHESIS);
7760    
7761                                    for (int i = 0; i < folderIds.length; i++) {
7762                                            query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
7763    
7764                                            if ((i + 1) < folderIds.length) {
7765                                                    query.append(WHERE_OR);
7766                                            }
7767                                    }
7768    
7769                                    query.append(StringPool.CLOSE_PARENTHESIS);
7770    
7771                                    conjunctionable = true;
7772                            }
7773    
7774                            if (orderByComparator != null) {
7775                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7776                                            orderByComparator);
7777                            }
7778                            else
7779                             if (pagination) {
7780                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7781                            }
7782    
7783                            String sql = query.toString();
7784    
7785                            Session session = null;
7786    
7787                            try {
7788                                    session = openSession();
7789    
7790                                    Query q = session.createQuery(sql);
7791    
7792                                    QueryPos qPos = QueryPos.getInstance(q);
7793    
7794                                    qPos.add(groupId);
7795    
7796                                    if (folderIds != null) {
7797                                            qPos.add(folderIds);
7798                                    }
7799    
7800                                    if (!pagination) {
7801                                            list = (List<JournalArticle>)QueryUtil.list(q,
7802                                                            getDialect(), start, end, false);
7803    
7804                                            Collections.sort(list);
7805    
7806                                            list = new UnmodifiableList<JournalArticle>(list);
7807                                    }
7808                                    else {
7809                                            list = (List<JournalArticle>)QueryUtil.list(q,
7810                                                            getDialect(), start, end);
7811                                    }
7812    
7813                                    cacheResult(list);
7814    
7815                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
7816                                            finderArgs, list);
7817                            }
7818                            catch (Exception e) {
7819                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
7820                                            finderArgs);
7821    
7822                                    throw processException(e);
7823                            }
7824                            finally {
7825                                    closeSession(session);
7826                            }
7827                    }
7828    
7829                    return list;
7830            }
7831    
7832            /**
7833             * Removes all the journal articles where groupId = &#63; and folderId = &#63; from the database.
7834             *
7835             * @param groupId the group ID
7836             * @param folderId the folder ID
7837             * @throws SystemException if a system exception occurred
7838             */
7839            public void removeByG_F(long groupId, long folderId)
7840                    throws SystemException {
7841                    for (JournalArticle journalArticle : findByG_F(groupId, folderId,
7842                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7843                            remove(journalArticle);
7844                    }
7845            }
7846    
7847            /**
7848             * Returns the number of journal articles where groupId = &#63; and folderId = &#63;.
7849             *
7850             * @param groupId the group ID
7851             * @param folderId the folder ID
7852             * @return the number of matching journal articles
7853             * @throws SystemException if a system exception occurred
7854             */
7855            public int countByG_F(long groupId, long folderId)
7856                    throws SystemException {
7857                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F;
7858    
7859                    Object[] finderArgs = new Object[] { groupId, folderId };
7860    
7861                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7862                                    this);
7863    
7864                    if (count == null) {
7865                            StringBundler query = new StringBundler(3);
7866    
7867                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
7868    
7869                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
7870    
7871                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
7872    
7873                            String sql = query.toString();
7874    
7875                            Session session = null;
7876    
7877                            try {
7878                                    session = openSession();
7879    
7880                                    Query q = session.createQuery(sql);
7881    
7882                                    QueryPos qPos = QueryPos.getInstance(q);
7883    
7884                                    qPos.add(groupId);
7885    
7886                                    qPos.add(folderId);
7887    
7888                                    count = (Long)q.uniqueResult();
7889    
7890                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
7891                            }
7892                            catch (Exception e) {
7893                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7894    
7895                                    throw processException(e);
7896                            }
7897                            finally {
7898                                    closeSession(session);
7899                            }
7900                    }
7901    
7902                    return count.intValue();
7903            }
7904    
7905            /**
7906             * Returns the number of journal articles where groupId = &#63; and folderId = any &#63;.
7907             *
7908             * @param groupId the group ID
7909             * @param folderIds the folder IDs
7910             * @return the number of matching journal articles
7911             * @throws SystemException if a system exception occurred
7912             */
7913            public int countByG_F(long groupId, long[] folderIds)
7914                    throws SystemException {
7915                    Object[] finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
7916    
7917                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
7918                                    finderArgs, this);
7919    
7920                    if (count == null) {
7921                            StringBundler query = new StringBundler();
7922    
7923                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
7924    
7925                            boolean conjunctionable = false;
7926    
7927                            if (conjunctionable) {
7928                                    query.append(WHERE_AND);
7929                            }
7930    
7931                            query.append(_FINDER_COLUMN_G_F_GROUPID_5);
7932    
7933                            conjunctionable = true;
7934    
7935                            if ((folderIds == null) || (folderIds.length > 0)) {
7936                                    if (conjunctionable) {
7937                                            query.append(WHERE_AND);
7938                                    }
7939    
7940                                    query.append(StringPool.OPEN_PARENTHESIS);
7941    
7942                                    for (int i = 0; i < folderIds.length; i++) {
7943                                            query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
7944    
7945                                            if ((i + 1) < folderIds.length) {
7946                                                    query.append(WHERE_OR);
7947                                            }
7948                                    }
7949    
7950                                    query.append(StringPool.CLOSE_PARENTHESIS);
7951    
7952                                    conjunctionable = true;
7953                            }
7954    
7955                            String sql = query.toString();
7956    
7957                            Session session = null;
7958    
7959                            try {
7960                                    session = openSession();
7961    
7962                                    Query q = session.createQuery(sql);
7963    
7964                                    QueryPos qPos = QueryPos.getInstance(q);
7965    
7966                                    qPos.add(groupId);
7967    
7968                                    if (folderIds != null) {
7969                                            qPos.add(folderIds);
7970                                    }
7971    
7972                                    count = (Long)q.uniqueResult();
7973    
7974                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
7975                                            finderArgs, count);
7976                            }
7977                            catch (Exception e) {
7978                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
7979                                            finderArgs);
7980    
7981                                    throw processException(e);
7982                            }
7983                            finally {
7984                                    closeSession(session);
7985                            }
7986                    }
7987    
7988                    return count.intValue();
7989            }
7990    
7991            /**
7992             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
7993             *
7994             * @param groupId the group ID
7995             * @param folderId the folder ID
7996             * @return the number of matching journal articles that the user has permission to view
7997             * @throws SystemException if a system exception occurred
7998             */
7999            public int filterCountByG_F(long groupId, long folderId)
8000                    throws SystemException {
8001                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8002                            return countByG_F(groupId, folderId);
8003                    }
8004    
8005                    StringBundler query = new StringBundler(3);
8006    
8007                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
8008    
8009                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8010    
8011                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
8012    
8013                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8014                                    JournalArticle.class.getName(),
8015                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8016    
8017                    Session session = null;
8018    
8019                    try {
8020                            session = openSession();
8021    
8022                            SQLQuery q = session.createSQLQuery(sql);
8023    
8024                            q.addScalar(COUNT_COLUMN_NAME,
8025                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
8026    
8027                            QueryPos qPos = QueryPos.getInstance(q);
8028    
8029                            qPos.add(groupId);
8030    
8031                            qPos.add(folderId);
8032    
8033                            Long count = (Long)q.uniqueResult();
8034    
8035                            return count.intValue();
8036                    }
8037                    catch (Exception e) {
8038                            throw processException(e);
8039                    }
8040                    finally {
8041                            closeSession(session);
8042                    }
8043            }
8044    
8045            /**
8046             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
8047             *
8048             * @param groupId the group ID
8049             * @param folderIds the folder IDs
8050             * @return the number of matching journal articles that the user has permission to view
8051             * @throws SystemException if a system exception occurred
8052             */
8053            public int filterCountByG_F(long groupId, long[] folderIds)
8054                    throws SystemException {
8055                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8056                            return countByG_F(groupId, folderIds);
8057                    }
8058    
8059                    StringBundler query = new StringBundler();
8060    
8061                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
8062    
8063                    boolean conjunctionable = false;
8064    
8065                    if (conjunctionable) {
8066                            query.append(WHERE_AND);
8067                    }
8068    
8069                    query.append(_FINDER_COLUMN_G_F_GROUPID_5);
8070    
8071                    conjunctionable = true;
8072    
8073                    if ((folderIds == null) || (folderIds.length > 0)) {
8074                            if (conjunctionable) {
8075                                    query.append(WHERE_AND);
8076                            }
8077    
8078                            query.append(StringPool.OPEN_PARENTHESIS);
8079    
8080                            for (int i = 0; i < folderIds.length; i++) {
8081                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
8082    
8083                                    if ((i + 1) < folderIds.length) {
8084                                            query.append(WHERE_OR);
8085                                    }
8086                            }
8087    
8088                            query.append(StringPool.CLOSE_PARENTHESIS);
8089    
8090                            conjunctionable = true;
8091                    }
8092    
8093                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8094                                    JournalArticle.class.getName(),
8095                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8096    
8097                    Session session = null;
8098    
8099                    try {
8100                            session = openSession();
8101    
8102                            SQLQuery q = session.createSQLQuery(sql);
8103    
8104                            q.addScalar(COUNT_COLUMN_NAME,
8105                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
8106    
8107                            QueryPos qPos = QueryPos.getInstance(q);
8108    
8109                            qPos.add(groupId);
8110    
8111                            if (folderIds != null) {
8112                                    qPos.add(folderIds);
8113                            }
8114    
8115                            Long count = (Long)q.uniqueResult();
8116    
8117                            return count.intValue();
8118                    }
8119                    catch (Exception e) {
8120                            throw processException(e);
8121                    }
8122                    finally {
8123                            closeSession(session);
8124                    }
8125            }
8126    
8127            private static final String _FINDER_COLUMN_G_F_GROUPID_2 = "journalArticle.groupId = ? AND ";
8128            private static final String _FINDER_COLUMN_G_F_GROUPID_5 = "(" +
8129                    removeConjunction(_FINDER_COLUMN_G_F_GROUPID_2) + ")";
8130            private static final String _FINDER_COLUMN_G_F_FOLDERID_2 = "journalArticle.folderId = ?";
8131            private static final String _FINDER_COLUMN_G_F_FOLDERID_5 = "(" +
8132                    removeConjunction(_FINDER_COLUMN_G_F_FOLDERID_2) + ")";
8133            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
8134                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
8135                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
8136                            "findByG_A",
8137                            new String[] {
8138                                    Long.class.getName(), String.class.getName(),
8139                                    
8140                            Integer.class.getName(), Integer.class.getName(),
8141                                    OrderByComparator.class.getName()
8142                            });
8143            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
8144                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
8145                            JournalArticleImpl.class,
8146                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A",
8147                            new String[] { Long.class.getName(), String.class.getName() },
8148                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
8149                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
8150                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
8151            public static final FinderPath FINDER_PATH_COUNT_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
8152                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
8153                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A",
8154                            new String[] { Long.class.getName(), String.class.getName() });
8155    
8156            /**
8157             * Returns all the journal articles where groupId = &#63; and articleId = &#63;.
8158             *
8159             * @param groupId the group ID
8160             * @param articleId the article ID
8161             * @return the matching journal articles
8162             * @throws SystemException if a system exception occurred
8163             */
8164            public List<JournalArticle> findByG_A(long groupId, String articleId)
8165                    throws SystemException {
8166                    return findByG_A(groupId, articleId, QueryUtil.ALL_POS,
8167                            QueryUtil.ALL_POS, null);
8168            }
8169    
8170            /**
8171             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63;.
8172             *
8173             * <p>
8174             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8175             * </p>
8176             *
8177             * @param groupId the group ID
8178             * @param articleId the article ID
8179             * @param start the lower bound of the range of journal articles
8180             * @param end the upper bound of the range of journal articles (not inclusive)
8181             * @return the range of matching journal articles
8182             * @throws SystemException if a system exception occurred
8183             */
8184            public List<JournalArticle> findByG_A(long groupId, String articleId,
8185                    int start, int end) throws SystemException {
8186                    return findByG_A(groupId, articleId, start, end, null);
8187            }
8188    
8189            /**
8190             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63;.
8191             *
8192             * <p>
8193             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8194             * </p>
8195             *
8196             * @param groupId the group ID
8197             * @param articleId the article ID
8198             * @param start the lower bound of the range of journal articles
8199             * @param end the upper bound of the range of journal articles (not inclusive)
8200             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8201             * @return the ordered range of matching journal articles
8202             * @throws SystemException if a system exception occurred
8203             */
8204            public List<JournalArticle> findByG_A(long groupId, String articleId,
8205                    int start, int end, OrderByComparator orderByComparator)
8206                    throws SystemException {
8207                    boolean pagination = true;
8208                    FinderPath finderPath = null;
8209                    Object[] finderArgs = null;
8210    
8211                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8212                                    (orderByComparator == null)) {
8213                            pagination = false;
8214                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A;
8215                            finderArgs = new Object[] { groupId, articleId };
8216                    }
8217                    else {
8218                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A;
8219                            finderArgs = new Object[] {
8220                                            groupId, articleId,
8221                                            
8222                                            start, end, orderByComparator
8223                                    };
8224                    }
8225    
8226                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
8227                                    finderArgs, this);
8228    
8229                    if ((list != null) && !list.isEmpty()) {
8230                            for (JournalArticle journalArticle : list) {
8231                                    if ((groupId != journalArticle.getGroupId()) ||
8232                                                    !Validator.equals(articleId,
8233                                                            journalArticle.getArticleId())) {
8234                                            list = null;
8235    
8236                                            break;
8237                                    }
8238                            }
8239                    }
8240    
8241                    if (list == null) {
8242                            StringBundler query = null;
8243    
8244                            if (orderByComparator != null) {
8245                                    query = new StringBundler(4 +
8246                                                    (orderByComparator.getOrderByFields().length * 3));
8247                            }
8248                            else {
8249                                    query = new StringBundler(4);
8250                            }
8251    
8252                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8253    
8254                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
8255    
8256                            boolean bindArticleId = false;
8257    
8258                            if (articleId == null) {
8259                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
8260                            }
8261                            else if (articleId.equals(StringPool.BLANK)) {
8262                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
8263                            }
8264                            else {
8265                                    bindArticleId = true;
8266    
8267                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
8268                            }
8269    
8270                            if (orderByComparator != null) {
8271                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8272                                            orderByComparator);
8273                            }
8274                            else
8275                             if (pagination) {
8276                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8277                            }
8278    
8279                            String sql = query.toString();
8280    
8281                            Session session = null;
8282    
8283                            try {
8284                                    session = openSession();
8285    
8286                                    Query q = session.createQuery(sql);
8287    
8288                                    QueryPos qPos = QueryPos.getInstance(q);
8289    
8290                                    qPos.add(groupId);
8291    
8292                                    if (bindArticleId) {
8293                                            qPos.add(articleId);
8294                                    }
8295    
8296                                    if (!pagination) {
8297                                            list = (List<JournalArticle>)QueryUtil.list(q,
8298                                                            getDialect(), start, end, false);
8299    
8300                                            Collections.sort(list);
8301    
8302                                            list = new UnmodifiableList<JournalArticle>(list);
8303                                    }
8304                                    else {
8305                                            list = (List<JournalArticle>)QueryUtil.list(q,
8306                                                            getDialect(), start, end);
8307                                    }
8308    
8309                                    cacheResult(list);
8310    
8311                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
8312                            }
8313                            catch (Exception e) {
8314                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8315    
8316                                    throw processException(e);
8317                            }
8318                            finally {
8319                                    closeSession(session);
8320                            }
8321                    }
8322    
8323                    return list;
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
8333             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
8334             * @throws SystemException if a system exception occurred
8335             */
8336            public JournalArticle findByG_A_First(long groupId, String articleId,
8337                    OrderByComparator orderByComparator)
8338                    throws NoSuchArticleException, SystemException {
8339                    JournalArticle journalArticle = fetchByG_A_First(groupId, articleId,
8340                                    orderByComparator);
8341    
8342                    if (journalArticle != null) {
8343                            return journalArticle;
8344                    }
8345    
8346                    StringBundler msg = new StringBundler(6);
8347    
8348                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8349    
8350                    msg.append("groupId=");
8351                    msg.append(groupId);
8352    
8353                    msg.append(", articleId=");
8354                    msg.append(articleId);
8355    
8356                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8357    
8358                    throw new NoSuchArticleException(msg.toString());
8359            }
8360    
8361            /**
8362             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63;.
8363             *
8364             * @param groupId the group ID
8365             * @param articleId the article ID
8366             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8367             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
8368             * @throws SystemException if a system exception occurred
8369             */
8370            public JournalArticle fetchByG_A_First(long groupId, String articleId,
8371                    OrderByComparator orderByComparator) throws SystemException {
8372                    List<JournalArticle> list = findByG_A(groupId, articleId, 0, 1,
8373                                    orderByComparator);
8374    
8375                    if (!list.isEmpty()) {
8376                            return list.get(0);
8377                    }
8378    
8379                    return null;
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
8389             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
8390             * @throws SystemException if a system exception occurred
8391             */
8392            public JournalArticle findByG_A_Last(long groupId, String articleId,
8393                    OrderByComparator orderByComparator)
8394                    throws NoSuchArticleException, SystemException {
8395                    JournalArticle journalArticle = fetchByG_A_Last(groupId, articleId,
8396                                    orderByComparator);
8397    
8398                    if (journalArticle != null) {
8399                            return journalArticle;
8400                    }
8401    
8402                    StringBundler msg = new StringBundler(6);
8403    
8404                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8405    
8406                    msg.append("groupId=");
8407                    msg.append(groupId);
8408    
8409                    msg.append(", articleId=");
8410                    msg.append(articleId);
8411    
8412                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8413    
8414                    throw new NoSuchArticleException(msg.toString());
8415            }
8416    
8417            /**
8418             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63;.
8419             *
8420             * @param groupId the group ID
8421             * @param articleId the article ID
8422             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8423             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
8424             * @throws SystemException if a system exception occurred
8425             */
8426            public JournalArticle fetchByG_A_Last(long groupId, String articleId,
8427                    OrderByComparator orderByComparator) throws SystemException {
8428                    int count = countByG_A(groupId, articleId);
8429    
8430                    List<JournalArticle> list = findByG_A(groupId, articleId, count - 1,
8431                                    count, orderByComparator);
8432    
8433                    if (!list.isEmpty()) {
8434                            return list.get(0);
8435                    }
8436    
8437                    return null;
8438            }
8439    
8440            /**
8441             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63;.
8442             *
8443             * @param id the primary key of the current journal article
8444             * @param groupId the group ID
8445             * @param articleId the article ID
8446             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8447             * @return the previous, current, and next journal article
8448             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
8449             * @throws SystemException if a system exception occurred
8450             */
8451            public JournalArticle[] findByG_A_PrevAndNext(long id, long groupId,
8452                    String articleId, OrderByComparator orderByComparator)
8453                    throws NoSuchArticleException, SystemException {
8454                    JournalArticle journalArticle = findByPrimaryKey(id);
8455    
8456                    Session session = null;
8457    
8458                    try {
8459                            session = openSession();
8460    
8461                            JournalArticle[] array = new JournalArticleImpl[3];
8462    
8463                            array[0] = getByG_A_PrevAndNext(session, journalArticle, groupId,
8464                                            articleId, orderByComparator, true);
8465    
8466                            array[1] = journalArticle;
8467    
8468                            array[2] = getByG_A_PrevAndNext(session, journalArticle, groupId,
8469                                            articleId, orderByComparator, false);
8470    
8471                            return array;
8472                    }
8473                    catch (Exception e) {
8474                            throw processException(e);
8475                    }
8476                    finally {
8477                            closeSession(session);
8478                    }
8479            }
8480    
8481            protected JournalArticle getByG_A_PrevAndNext(Session session,
8482                    JournalArticle journalArticle, long groupId, String articleId,
8483                    OrderByComparator orderByComparator, boolean previous) {
8484                    StringBundler query = null;
8485    
8486                    if (orderByComparator != null) {
8487                            query = new StringBundler(6 +
8488                                            (orderByComparator.getOrderByFields().length * 6));
8489                    }
8490                    else {
8491                            query = new StringBundler(3);
8492                    }
8493    
8494                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8495    
8496                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
8497    
8498                    boolean bindArticleId = false;
8499    
8500                    if (articleId == null) {
8501                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
8502                    }
8503                    else if (articleId.equals(StringPool.BLANK)) {
8504                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
8505                    }
8506                    else {
8507                            bindArticleId = true;
8508    
8509                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
8510                    }
8511    
8512                    if (orderByComparator != null) {
8513                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8514    
8515                            if (orderByConditionFields.length > 0) {
8516                                    query.append(WHERE_AND);
8517                            }
8518    
8519                            for (int i = 0; i < orderByConditionFields.length; i++) {
8520                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8521                                    query.append(orderByConditionFields[i]);
8522    
8523                                    if ((i + 1) < orderByConditionFields.length) {
8524                                            if (orderByComparator.isAscending() ^ previous) {
8525                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8526                                            }
8527                                            else {
8528                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8529                                            }
8530                                    }
8531                                    else {
8532                                            if (orderByComparator.isAscending() ^ previous) {
8533                                                    query.append(WHERE_GREATER_THAN);
8534                                            }
8535                                            else {
8536                                                    query.append(WHERE_LESSER_THAN);
8537                                            }
8538                                    }
8539                            }
8540    
8541                            query.append(ORDER_BY_CLAUSE);
8542    
8543                            String[] orderByFields = orderByComparator.getOrderByFields();
8544    
8545                            for (int i = 0; i < orderByFields.length; i++) {
8546                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8547                                    query.append(orderByFields[i]);
8548    
8549                                    if ((i + 1) < orderByFields.length) {
8550                                            if (orderByComparator.isAscending() ^ previous) {
8551                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8552                                            }
8553                                            else {
8554                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8555                                            }
8556                                    }
8557                                    else {
8558                                            if (orderByComparator.isAscending() ^ previous) {
8559                                                    query.append(ORDER_BY_ASC);
8560                                            }
8561                                            else {
8562                                                    query.append(ORDER_BY_DESC);
8563                                            }
8564                                    }
8565                            }
8566                    }
8567                    else {
8568                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8569                    }
8570    
8571                    String sql = query.toString();
8572    
8573                    Query q = session.createQuery(sql);
8574    
8575                    q.setFirstResult(0);
8576                    q.setMaxResults(2);
8577    
8578                    QueryPos qPos = QueryPos.getInstance(q);
8579    
8580                    qPos.add(groupId);
8581    
8582                    if (bindArticleId) {
8583                            qPos.add(articleId);
8584                    }
8585    
8586                    if (orderByComparator != null) {
8587                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
8588    
8589                            for (Object value : values) {
8590                                    qPos.add(value);
8591                            }
8592                    }
8593    
8594                    List<JournalArticle> list = q.list();
8595    
8596                    if (list.size() == 2) {
8597                            return list.get(1);
8598                    }
8599                    else {
8600                            return null;
8601                    }
8602            }
8603    
8604            /**
8605             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
8606             *
8607             * @param groupId the group ID
8608             * @param articleId the article ID
8609             * @return the matching journal articles that the user has permission to view
8610             * @throws SystemException if a system exception occurred
8611             */
8612            public List<JournalArticle> filterFindByG_A(long groupId, String articleId)
8613                    throws SystemException {
8614                    return filterFindByG_A(groupId, articleId, QueryUtil.ALL_POS,
8615                            QueryUtil.ALL_POS, null);
8616            }
8617    
8618            /**
8619             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
8620             *
8621             * <p>
8622             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8623             * </p>
8624             *
8625             * @param groupId the group ID
8626             * @param articleId the article ID
8627             * @param start the lower bound of the range of journal articles
8628             * @param end the upper bound of the range of journal articles (not inclusive)
8629             * @return the range of matching journal articles that the user has permission to view
8630             * @throws SystemException if a system exception occurred
8631             */
8632            public List<JournalArticle> filterFindByG_A(long groupId, String articleId,
8633                    int start, int end) throws SystemException {
8634                    return filterFindByG_A(groupId, articleId, start, end, null);
8635            }
8636    
8637            /**
8638             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and articleId = &#63;.
8639             *
8640             * <p>
8641             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8642             * </p>
8643             *
8644             * @param groupId the group ID
8645             * @param articleId the article ID
8646             * @param start the lower bound of the range of journal articles
8647             * @param end the upper bound of the range of journal articles (not inclusive)
8648             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8649             * @return the ordered range of matching journal articles that the user has permission to view
8650             * @throws SystemException if a system exception occurred
8651             */
8652            public List<JournalArticle> filterFindByG_A(long groupId, String articleId,
8653                    int start, int end, OrderByComparator orderByComparator)
8654                    throws SystemException {
8655                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8656                            return findByG_A(groupId, articleId, start, end, orderByComparator);
8657                    }
8658    
8659                    StringBundler query = null;
8660    
8661                    if (orderByComparator != null) {
8662                            query = new StringBundler(4 +
8663                                            (orderByComparator.getOrderByFields().length * 3));
8664                    }
8665                    else {
8666                            query = new StringBundler(4);
8667                    }
8668    
8669                    if (getDB().isSupportsInlineDistinct()) {
8670                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8671                    }
8672                    else {
8673                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8674                    }
8675    
8676                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
8677    
8678                    boolean bindArticleId = false;
8679    
8680                    if (articleId == null) {
8681                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
8682                    }
8683                    else if (articleId.equals(StringPool.BLANK)) {
8684                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
8685                    }
8686                    else {
8687                            bindArticleId = true;
8688    
8689                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
8690                    }
8691    
8692                    if (!getDB().isSupportsInlineDistinct()) {
8693                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8694                    }
8695    
8696                    if (orderByComparator != null) {
8697                            if (getDB().isSupportsInlineDistinct()) {
8698                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8699                                            orderByComparator);
8700                            }
8701                            else {
8702                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8703                                            orderByComparator);
8704                            }
8705                    }
8706                    else {
8707                            if (getDB().isSupportsInlineDistinct()) {
8708                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8709                            }
8710                            else {
8711                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8712                            }
8713                    }
8714    
8715                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8716                                    JournalArticle.class.getName(),
8717                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8718    
8719                    Session session = null;
8720    
8721                    try {
8722                            session = openSession();
8723    
8724                            SQLQuery q = session.createSQLQuery(sql);
8725    
8726                            if (getDB().isSupportsInlineDistinct()) {
8727                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8728                            }
8729                            else {
8730                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8731                            }
8732    
8733                            QueryPos qPos = QueryPos.getInstance(q);
8734    
8735                            qPos.add(groupId);
8736    
8737                            if (bindArticleId) {
8738                                    qPos.add(articleId);
8739                            }
8740    
8741                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
8742                                    end);
8743                    }
8744                    catch (Exception e) {
8745                            throw processException(e);
8746                    }
8747                    finally {
8748                            closeSession(session);
8749                    }
8750            }
8751    
8752            /**
8753             * 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;.
8754             *
8755             * @param id the primary key of the current journal article
8756             * @param groupId the group ID
8757             * @param articleId the article ID
8758             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8759             * @return the previous, current, and next journal article
8760             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
8761             * @throws SystemException if a system exception occurred
8762             */
8763            public JournalArticle[] filterFindByG_A_PrevAndNext(long id, long groupId,
8764                    String articleId, OrderByComparator orderByComparator)
8765                    throws NoSuchArticleException, SystemException {
8766                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8767                            return findByG_A_PrevAndNext(id, groupId, articleId,
8768                                    orderByComparator);
8769                    }
8770    
8771                    JournalArticle journalArticle = findByPrimaryKey(id);
8772    
8773                    Session session = null;
8774    
8775                    try {
8776                            session = openSession();
8777    
8778                            JournalArticle[] array = new JournalArticleImpl[3];
8779    
8780                            array[0] = filterGetByG_A_PrevAndNext(session, journalArticle,
8781                                            groupId, articleId, orderByComparator, true);
8782    
8783                            array[1] = journalArticle;
8784    
8785                            array[2] = filterGetByG_A_PrevAndNext(session, journalArticle,
8786                                            groupId, articleId, orderByComparator, false);
8787    
8788                            return array;
8789                    }
8790                    catch (Exception e) {
8791                            throw processException(e);
8792                    }
8793                    finally {
8794                            closeSession(session);
8795                    }
8796            }
8797    
8798            protected JournalArticle filterGetByG_A_PrevAndNext(Session session,
8799                    JournalArticle journalArticle, long groupId, String articleId,
8800                    OrderByComparator orderByComparator, boolean previous) {
8801                    StringBundler query = null;
8802    
8803                    if (orderByComparator != null) {
8804                            query = new StringBundler(6 +
8805                                            (orderByComparator.getOrderByFields().length * 6));
8806                    }
8807                    else {
8808                            query = new StringBundler(3);
8809                    }
8810    
8811                    if (getDB().isSupportsInlineDistinct()) {
8812                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8813                    }
8814                    else {
8815                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8816                    }
8817    
8818                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
8819    
8820                    boolean bindArticleId = false;
8821    
8822                    if (articleId == null) {
8823                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
8824                    }
8825                    else if (articleId.equals(StringPool.BLANK)) {
8826                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
8827                    }
8828                    else {
8829                            bindArticleId = true;
8830    
8831                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
8832                    }
8833    
8834                    if (!getDB().isSupportsInlineDistinct()) {
8835                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8836                    }
8837    
8838                    if (orderByComparator != null) {
8839                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8840    
8841                            if (orderByConditionFields.length > 0) {
8842                                    query.append(WHERE_AND);
8843                            }
8844    
8845                            for (int i = 0; i < orderByConditionFields.length; i++) {
8846                                    if (getDB().isSupportsInlineDistinct()) {
8847                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8848                                    }
8849                                    else {
8850                                            query.append(_ORDER_BY_ENTITY_TABLE);
8851                                    }
8852    
8853                                    query.append(orderByConditionFields[i]);
8854    
8855                                    if ((i + 1) < orderByConditionFields.length) {
8856                                            if (orderByComparator.isAscending() ^ previous) {
8857                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8858                                            }
8859                                            else {
8860                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8861                                            }
8862                                    }
8863                                    else {
8864                                            if (orderByComparator.isAscending() ^ previous) {
8865                                                    query.append(WHERE_GREATER_THAN);
8866                                            }
8867                                            else {
8868                                                    query.append(WHERE_LESSER_THAN);
8869                                            }
8870                                    }
8871                            }
8872    
8873                            query.append(ORDER_BY_CLAUSE);
8874    
8875                            String[] orderByFields = orderByComparator.getOrderByFields();
8876    
8877                            for (int i = 0; i < orderByFields.length; i++) {
8878                                    if (getDB().isSupportsInlineDistinct()) {
8879                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8880                                    }
8881                                    else {
8882                                            query.append(_ORDER_BY_ENTITY_TABLE);
8883                                    }
8884    
8885                                    query.append(orderByFields[i]);
8886    
8887                                    if ((i + 1) < orderByFields.length) {
8888                                            if (orderByComparator.isAscending() ^ previous) {
8889                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8890                                            }
8891                                            else {
8892                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8893                                            }
8894                                    }
8895                                    else {
8896                                            if (orderByComparator.isAscending() ^ previous) {
8897                                                    query.append(ORDER_BY_ASC);
8898                                            }
8899                                            else {
8900                                                    query.append(ORDER_BY_DESC);
8901                                            }
8902                                    }
8903                            }
8904                    }
8905                    else {
8906                            if (getDB().isSupportsInlineDistinct()) {
8907                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8908                            }
8909                            else {
8910                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8911                            }
8912                    }
8913    
8914                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8915                                    JournalArticle.class.getName(),
8916                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8917    
8918                    SQLQuery q = session.createSQLQuery(sql);
8919    
8920                    q.setFirstResult(0);
8921                    q.setMaxResults(2);
8922    
8923                    if (getDB().isSupportsInlineDistinct()) {
8924                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8925                    }
8926                    else {
8927                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8928                    }
8929    
8930                    QueryPos qPos = QueryPos.getInstance(q);
8931    
8932                    qPos.add(groupId);
8933    
8934                    if (bindArticleId) {
8935                            qPos.add(articleId);
8936                    }
8937    
8938                    if (orderByComparator != null) {
8939                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
8940    
8941                            for (Object value : values) {
8942                                    qPos.add(value);
8943                            }
8944                    }
8945    
8946                    List<JournalArticle> list = q.list();
8947    
8948                    if (list.size() == 2) {
8949                            return list.get(1);
8950                    }
8951                    else {
8952                            return null;
8953                    }
8954            }
8955    
8956            /**
8957             * Removes all the journal articles where groupId = &#63; and articleId = &#63; from the database.
8958             *
8959             * @param groupId the group ID
8960             * @param articleId the article ID
8961             * @throws SystemException if a system exception occurred
8962             */
8963            public void removeByG_A(long groupId, String articleId)
8964                    throws SystemException {
8965                    for (JournalArticle journalArticle : findByG_A(groupId, articleId,
8966                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8967                            remove(journalArticle);
8968                    }
8969            }
8970    
8971            /**
8972             * Returns the number of journal articles where groupId = &#63; and articleId = &#63;.
8973             *
8974             * @param groupId the group ID
8975             * @param articleId the article ID
8976             * @return the number of matching journal articles
8977             * @throws SystemException if a system exception occurred
8978             */
8979            public int countByG_A(long groupId, String articleId)
8980                    throws SystemException {
8981                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A;
8982    
8983                    Object[] finderArgs = new Object[] { groupId, articleId };
8984    
8985                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
8986                                    this);
8987    
8988                    if (count == null) {
8989                            StringBundler query = new StringBundler(3);
8990    
8991                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
8992    
8993                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
8994    
8995                            boolean bindArticleId = false;
8996    
8997                            if (articleId == null) {
8998                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
8999                            }
9000                            else if (articleId.equals(StringPool.BLANK)) {
9001                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
9002                            }
9003                            else {
9004                                    bindArticleId = true;
9005    
9006                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
9007                            }
9008    
9009                            String sql = query.toString();
9010    
9011                            Session session = null;
9012    
9013                            try {
9014                                    session = openSession();
9015    
9016                                    Query q = session.createQuery(sql);
9017    
9018                                    QueryPos qPos = QueryPos.getInstance(q);
9019    
9020                                    qPos.add(groupId);
9021    
9022                                    if (bindArticleId) {
9023                                            qPos.add(articleId);
9024                                    }
9025    
9026                                    count = (Long)q.uniqueResult();
9027    
9028                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
9029                            }
9030                            catch (Exception e) {
9031                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9032    
9033                                    throw processException(e);
9034                            }
9035                            finally {
9036                                    closeSession(session);
9037                            }
9038                    }
9039    
9040                    return count.intValue();
9041            }
9042    
9043            /**
9044             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
9045             *
9046             * @param groupId the group ID
9047             * @param articleId the article ID
9048             * @return the number of matching journal articles that the user has permission to view
9049             * @throws SystemException if a system exception occurred
9050             */
9051            public int filterCountByG_A(long groupId, String articleId)
9052                    throws SystemException {
9053                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9054                            return countByG_A(groupId, articleId);
9055                    }
9056    
9057                    StringBundler query = new StringBundler(3);
9058    
9059                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
9060    
9061                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
9062    
9063                    boolean bindArticleId = false;
9064    
9065                    if (articleId == null) {
9066                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
9067                    }
9068                    else if (articleId.equals(StringPool.BLANK)) {
9069                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
9070                    }
9071                    else {
9072                            bindArticleId = true;
9073    
9074                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
9075                    }
9076    
9077                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9078                                    JournalArticle.class.getName(),
9079                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9080    
9081                    Session session = null;
9082    
9083                    try {
9084                            session = openSession();
9085    
9086                            SQLQuery q = session.createSQLQuery(sql);
9087    
9088                            q.addScalar(COUNT_COLUMN_NAME,
9089                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9090    
9091                            QueryPos qPos = QueryPos.getInstance(q);
9092    
9093                            qPos.add(groupId);
9094    
9095                            if (bindArticleId) {
9096                                    qPos.add(articleId);
9097                            }
9098    
9099                            Long count = (Long)q.uniqueResult();
9100    
9101                            return count.intValue();
9102                    }
9103                    catch (Exception e) {
9104                            throw processException(e);
9105                    }
9106                    finally {
9107                            closeSession(session);
9108                    }
9109            }
9110    
9111            private static final String _FINDER_COLUMN_G_A_GROUPID_2 = "journalArticle.groupId = ? AND ";
9112            private static final String _FINDER_COLUMN_G_A_ARTICLEID_1 = "journalArticle.articleId IS NULL";
9113            private static final String _FINDER_COLUMN_G_A_ARTICLEID_2 = "journalArticle.articleId = ?";
9114            private static final String _FINDER_COLUMN_G_A_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '')";
9115            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
9116                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
9117                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
9118                            "findByG_UT",
9119                            new String[] {
9120                                    Long.class.getName(), String.class.getName(),
9121                                    
9122                            Integer.class.getName(), Integer.class.getName(),
9123                                    OrderByComparator.class.getName()
9124                            });
9125            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
9126                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
9127                            JournalArticleImpl.class,
9128                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_UT",
9129                            new String[] { Long.class.getName(), String.class.getName() },
9130                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
9131                            JournalArticleModelImpl.URLTITLE_COLUMN_BITMASK |
9132                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
9133                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
9134            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
9135                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
9136                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT",
9137                            new String[] { Long.class.getName(), String.class.getName() });
9138    
9139            /**
9140             * Returns all the journal articles where groupId = &#63; and urlTitle = &#63;.
9141             *
9142             * @param groupId the group ID
9143             * @param urlTitle the url title
9144             * @return the matching journal articles
9145             * @throws SystemException if a system exception occurred
9146             */
9147            public List<JournalArticle> findByG_UT(long groupId, String urlTitle)
9148                    throws SystemException {
9149                    return findByG_UT(groupId, urlTitle, QueryUtil.ALL_POS,
9150                            QueryUtil.ALL_POS, null);
9151            }
9152    
9153            /**
9154             * Returns a range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
9155             *
9156             * <p>
9157             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9158             * </p>
9159             *
9160             * @param groupId the group ID
9161             * @param urlTitle the url title
9162             * @param start the lower bound of the range of journal articles
9163             * @param end the upper bound of the range of journal articles (not inclusive)
9164             * @return the range of matching journal articles
9165             * @throws SystemException if a system exception occurred
9166             */
9167            public List<JournalArticle> findByG_UT(long groupId, String urlTitle,
9168                    int start, int end) throws SystemException {
9169                    return findByG_UT(groupId, urlTitle, start, end, null);
9170            }
9171    
9172            /**
9173             * Returns an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
9174             *
9175             * <p>
9176             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9177             * </p>
9178             *
9179             * @param groupId the group ID
9180             * @param urlTitle the url title
9181             * @param start the lower bound of the range of journal articles
9182             * @param end the upper bound of the range of journal articles (not inclusive)
9183             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9184             * @return the ordered range of matching journal articles
9185             * @throws SystemException if a system exception occurred
9186             */
9187            public List<JournalArticle> findByG_UT(long groupId, String urlTitle,
9188                    int start, int end, OrderByComparator orderByComparator)
9189                    throws SystemException {
9190                    boolean pagination = true;
9191                    FinderPath finderPath = null;
9192                    Object[] finderArgs = null;
9193    
9194                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9195                                    (orderByComparator == null)) {
9196                            pagination = false;
9197                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT;
9198                            finderArgs = new Object[] { groupId, urlTitle };
9199                    }
9200                    else {
9201                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT;
9202                            finderArgs = new Object[] {
9203                                            groupId, urlTitle,
9204                                            
9205                                            start, end, orderByComparator
9206                                    };
9207                    }
9208    
9209                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
9210                                    finderArgs, this);
9211    
9212                    if ((list != null) && !list.isEmpty()) {
9213                            for (JournalArticle journalArticle : list) {
9214                                    if ((groupId != journalArticle.getGroupId()) ||
9215                                                    !Validator.equals(urlTitle, journalArticle.getUrlTitle())) {
9216                                            list = null;
9217    
9218                                            break;
9219                                    }
9220                            }
9221                    }
9222    
9223                    if (list == null) {
9224                            StringBundler query = null;
9225    
9226                            if (orderByComparator != null) {
9227                                    query = new StringBundler(4 +
9228                                                    (orderByComparator.getOrderByFields().length * 3));
9229                            }
9230                            else {
9231                                    query = new StringBundler(4);
9232                            }
9233    
9234                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9235    
9236                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
9237    
9238                            boolean bindUrlTitle = false;
9239    
9240                            if (urlTitle == null) {
9241                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
9242                            }
9243                            else if (urlTitle.equals(StringPool.BLANK)) {
9244                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
9245                            }
9246                            else {
9247                                    bindUrlTitle = true;
9248    
9249                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
9250                            }
9251    
9252                            if (orderByComparator != null) {
9253                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9254                                            orderByComparator);
9255                            }
9256                            else
9257                             if (pagination) {
9258                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9259                            }
9260    
9261                            String sql = query.toString();
9262    
9263                            Session session = null;
9264    
9265                            try {
9266                                    session = openSession();
9267    
9268                                    Query q = session.createQuery(sql);
9269    
9270                                    QueryPos qPos = QueryPos.getInstance(q);
9271    
9272                                    qPos.add(groupId);
9273    
9274                                    if (bindUrlTitle) {
9275                                            qPos.add(urlTitle);
9276                                    }
9277    
9278                                    if (!pagination) {
9279                                            list = (List<JournalArticle>)QueryUtil.list(q,
9280                                                            getDialect(), start, end, false);
9281    
9282                                            Collections.sort(list);
9283    
9284                                            list = new UnmodifiableList<JournalArticle>(list);
9285                                    }
9286                                    else {
9287                                            list = (List<JournalArticle>)QueryUtil.list(q,
9288                                                            getDialect(), start, end);
9289                                    }
9290    
9291                                    cacheResult(list);
9292    
9293                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
9294                            }
9295                            catch (Exception e) {
9296                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9297    
9298                                    throw processException(e);
9299                            }
9300                            finally {
9301                                    closeSession(session);
9302                            }
9303                    }
9304    
9305                    return list;
9306            }
9307    
9308            /**
9309             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
9310             *
9311             * @param groupId the group ID
9312             * @param urlTitle the url title
9313             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9314             * @return the first matching journal article
9315             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9316             * @throws SystemException if a system exception occurred
9317             */
9318            public JournalArticle findByG_UT_First(long groupId, String urlTitle,
9319                    OrderByComparator orderByComparator)
9320                    throws NoSuchArticleException, SystemException {
9321                    JournalArticle journalArticle = fetchByG_UT_First(groupId, urlTitle,
9322                                    orderByComparator);
9323    
9324                    if (journalArticle != null) {
9325                            return journalArticle;
9326                    }
9327    
9328                    StringBundler msg = new StringBundler(6);
9329    
9330                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9331    
9332                    msg.append("groupId=");
9333                    msg.append(groupId);
9334    
9335                    msg.append(", urlTitle=");
9336                    msg.append(urlTitle);
9337    
9338                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9339    
9340                    throw new NoSuchArticleException(msg.toString());
9341            }
9342    
9343            /**
9344             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
9345             *
9346             * @param groupId the group ID
9347             * @param urlTitle the url title
9348             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9349             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
9350             * @throws SystemException if a system exception occurred
9351             */
9352            public JournalArticle fetchByG_UT_First(long groupId, String urlTitle,
9353                    OrderByComparator orderByComparator) throws SystemException {
9354                    List<JournalArticle> list = findByG_UT(groupId, urlTitle, 0, 1,
9355                                    orderByComparator);
9356    
9357                    if (!list.isEmpty()) {
9358                            return list.get(0);
9359                    }
9360    
9361                    return null;
9362            }
9363    
9364            /**
9365             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
9366             *
9367             * @param groupId the group ID
9368             * @param urlTitle the url title
9369             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9370             * @return the last matching journal article
9371             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9372             * @throws SystemException if a system exception occurred
9373             */
9374            public JournalArticle findByG_UT_Last(long groupId, String urlTitle,
9375                    OrderByComparator orderByComparator)
9376                    throws NoSuchArticleException, SystemException {
9377                    JournalArticle journalArticle = fetchByG_UT_Last(groupId, urlTitle,
9378                                    orderByComparator);
9379    
9380                    if (journalArticle != null) {
9381                            return journalArticle;
9382                    }
9383    
9384                    StringBundler msg = new StringBundler(6);
9385    
9386                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9387    
9388                    msg.append("groupId=");
9389                    msg.append(groupId);
9390    
9391                    msg.append(", urlTitle=");
9392                    msg.append(urlTitle);
9393    
9394                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9395    
9396                    throw new NoSuchArticleException(msg.toString());
9397            }
9398    
9399            /**
9400             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
9401             *
9402             * @param groupId the group ID
9403             * @param urlTitle the url title
9404             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9405             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
9406             * @throws SystemException if a system exception occurred
9407             */
9408            public JournalArticle fetchByG_UT_Last(long groupId, String urlTitle,
9409                    OrderByComparator orderByComparator) throws SystemException {
9410                    int count = countByG_UT(groupId, urlTitle);
9411    
9412                    List<JournalArticle> list = findByG_UT(groupId, urlTitle, count - 1,
9413                                    count, orderByComparator);
9414    
9415                    if (!list.isEmpty()) {
9416                            return list.get(0);
9417                    }
9418    
9419                    return null;
9420            }
9421    
9422            /**
9423             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
9424             *
9425             * @param id the primary key of the current journal article
9426             * @param groupId the group ID
9427             * @param urlTitle the url title
9428             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9429             * @return the previous, current, and next journal article
9430             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
9431             * @throws SystemException if a system exception occurred
9432             */
9433            public JournalArticle[] findByG_UT_PrevAndNext(long id, long groupId,
9434                    String urlTitle, OrderByComparator orderByComparator)
9435                    throws NoSuchArticleException, SystemException {
9436                    JournalArticle journalArticle = findByPrimaryKey(id);
9437    
9438                    Session session = null;
9439    
9440                    try {
9441                            session = openSession();
9442    
9443                            JournalArticle[] array = new JournalArticleImpl[3];
9444    
9445                            array[0] = getByG_UT_PrevAndNext(session, journalArticle, groupId,
9446                                            urlTitle, orderByComparator, true);
9447    
9448                            array[1] = journalArticle;
9449    
9450                            array[2] = getByG_UT_PrevAndNext(session, journalArticle, groupId,
9451                                            urlTitle, orderByComparator, false);
9452    
9453                            return array;
9454                    }
9455                    catch (Exception e) {
9456                            throw processException(e);
9457                    }
9458                    finally {
9459                            closeSession(session);
9460                    }
9461            }
9462    
9463            protected JournalArticle getByG_UT_PrevAndNext(Session session,
9464                    JournalArticle journalArticle, long groupId, String urlTitle,
9465                    OrderByComparator orderByComparator, boolean previous) {
9466                    StringBundler query = null;
9467    
9468                    if (orderByComparator != null) {
9469                            query = new StringBundler(6 +
9470                                            (orderByComparator.getOrderByFields().length * 6));
9471                    }
9472                    else {
9473                            query = new StringBundler(3);
9474                    }
9475    
9476                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9477    
9478                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
9479    
9480                    boolean bindUrlTitle = false;
9481    
9482                    if (urlTitle == null) {
9483                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
9484                    }
9485                    else if (urlTitle.equals(StringPool.BLANK)) {
9486                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
9487                    }
9488                    else {
9489                            bindUrlTitle = true;
9490    
9491                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
9492                    }
9493    
9494                    if (orderByComparator != null) {
9495                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9496    
9497                            if (orderByConditionFields.length > 0) {
9498                                    query.append(WHERE_AND);
9499                            }
9500    
9501                            for (int i = 0; i < orderByConditionFields.length; i++) {
9502                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9503                                    query.append(orderByConditionFields[i]);
9504    
9505                                    if ((i + 1) < orderByConditionFields.length) {
9506                                            if (orderByComparator.isAscending() ^ previous) {
9507                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9508                                            }
9509                                            else {
9510                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9511                                            }
9512                                    }
9513                                    else {
9514                                            if (orderByComparator.isAscending() ^ previous) {
9515                                                    query.append(WHERE_GREATER_THAN);
9516                                            }
9517                                            else {
9518                                                    query.append(WHERE_LESSER_THAN);
9519                                            }
9520                                    }
9521                            }
9522    
9523                            query.append(ORDER_BY_CLAUSE);
9524    
9525                            String[] orderByFields = orderByComparator.getOrderByFields();
9526    
9527                            for (int i = 0; i < orderByFields.length; i++) {
9528                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9529                                    query.append(orderByFields[i]);
9530    
9531                                    if ((i + 1) < orderByFields.length) {
9532                                            if (orderByComparator.isAscending() ^ previous) {
9533                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9534                                            }
9535                                            else {
9536                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9537                                            }
9538                                    }
9539                                    else {
9540                                            if (orderByComparator.isAscending() ^ previous) {
9541                                                    query.append(ORDER_BY_ASC);
9542                                            }
9543                                            else {
9544                                                    query.append(ORDER_BY_DESC);
9545                                            }
9546                                    }
9547                            }
9548                    }
9549                    else {
9550                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9551                    }
9552    
9553                    String sql = query.toString();
9554    
9555                    Query q = session.createQuery(sql);
9556    
9557                    q.setFirstResult(0);
9558                    q.setMaxResults(2);
9559    
9560                    QueryPos qPos = QueryPos.getInstance(q);
9561    
9562                    qPos.add(groupId);
9563    
9564                    if (bindUrlTitle) {
9565                            qPos.add(urlTitle);
9566                    }
9567    
9568                    if (orderByComparator != null) {
9569                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
9570    
9571                            for (Object value : values) {
9572                                    qPos.add(value);
9573                            }
9574                    }
9575    
9576                    List<JournalArticle> list = q.list();
9577    
9578                    if (list.size() == 2) {
9579                            return list.get(1);
9580                    }
9581                    else {
9582                            return null;
9583                    }
9584            }
9585    
9586            /**
9587             * Returns all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
9588             *
9589             * @param groupId the group ID
9590             * @param urlTitle the url title
9591             * @return the matching journal articles that the user has permission to view
9592             * @throws SystemException if a system exception occurred
9593             */
9594            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle)
9595                    throws SystemException {
9596                    return filterFindByG_UT(groupId, urlTitle, QueryUtil.ALL_POS,
9597                            QueryUtil.ALL_POS, null);
9598            }
9599    
9600            /**
9601             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
9602             *
9603             * <p>
9604             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9605             * </p>
9606             *
9607             * @param groupId the group ID
9608             * @param urlTitle the url title
9609             * @param start the lower bound of the range of journal articles
9610             * @param end the upper bound of the range of journal articles (not inclusive)
9611             * @return the range of matching journal articles that the user has permission to view
9612             * @throws SystemException if a system exception occurred
9613             */
9614            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle,
9615                    int start, int end) throws SystemException {
9616                    return filterFindByG_UT(groupId, urlTitle, start, end, null);
9617            }
9618    
9619            /**
9620             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and urlTitle = &#63;.
9621             *
9622             * <p>
9623             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9624             * </p>
9625             *
9626             * @param groupId the group ID
9627             * @param urlTitle the url title
9628             * @param start the lower bound of the range of journal articles
9629             * @param end the upper bound of the range of journal articles (not inclusive)
9630             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9631             * @return the ordered range of matching journal articles that the user has permission to view
9632             * @throws SystemException if a system exception occurred
9633             */
9634            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle,
9635                    int start, int end, OrderByComparator orderByComparator)
9636                    throws SystemException {
9637                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9638                            return findByG_UT(groupId, urlTitle, start, end, orderByComparator);
9639                    }
9640    
9641                    StringBundler query = null;
9642    
9643                    if (orderByComparator != null) {
9644                            query = new StringBundler(4 +
9645                                            (orderByComparator.getOrderByFields().length * 3));
9646                    }
9647                    else {
9648                            query = new StringBundler(4);
9649                    }
9650    
9651                    if (getDB().isSupportsInlineDistinct()) {
9652                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
9653                    }
9654                    else {
9655                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
9656                    }
9657    
9658                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
9659    
9660                    boolean bindUrlTitle = false;
9661    
9662                    if (urlTitle == null) {
9663                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
9664                    }
9665                    else if (urlTitle.equals(StringPool.BLANK)) {
9666                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
9667                    }
9668                    else {
9669                            bindUrlTitle = true;
9670    
9671                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
9672                    }
9673    
9674                    if (!getDB().isSupportsInlineDistinct()) {
9675                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
9676                    }
9677    
9678                    if (orderByComparator != null) {
9679                            if (getDB().isSupportsInlineDistinct()) {
9680                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9681                                            orderByComparator);
9682                            }
9683                            else {
9684                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
9685                                            orderByComparator);
9686                            }
9687                    }
9688                    else {
9689                            if (getDB().isSupportsInlineDistinct()) {
9690                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9691                            }
9692                            else {
9693                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
9694                            }
9695                    }
9696    
9697                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9698                                    JournalArticle.class.getName(),
9699                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9700    
9701                    Session session = null;
9702    
9703                    try {
9704                            session = openSession();
9705    
9706                            SQLQuery q = session.createSQLQuery(sql);
9707    
9708                            if (getDB().isSupportsInlineDistinct()) {
9709                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
9710                            }
9711                            else {
9712                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
9713                            }
9714    
9715                            QueryPos qPos = QueryPos.getInstance(q);
9716    
9717                            qPos.add(groupId);
9718    
9719                            if (bindUrlTitle) {
9720                                    qPos.add(urlTitle);
9721                            }
9722    
9723                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
9724                                    end);
9725                    }
9726                    catch (Exception e) {
9727                            throw processException(e);
9728                    }
9729                    finally {
9730                            closeSession(session);
9731                    }
9732            }
9733    
9734            /**
9735             * 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;.
9736             *
9737             * @param id the primary key of the current journal article
9738             * @param groupId the group ID
9739             * @param urlTitle the url title
9740             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9741             * @return the previous, current, and next journal article
9742             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
9743             * @throws SystemException if a system exception occurred
9744             */
9745            public JournalArticle[] filterFindByG_UT_PrevAndNext(long id, long groupId,
9746                    String urlTitle, OrderByComparator orderByComparator)
9747                    throws NoSuchArticleException, SystemException {
9748                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9749                            return findByG_UT_PrevAndNext(id, groupId, urlTitle,
9750                                    orderByComparator);
9751                    }
9752    
9753                    JournalArticle journalArticle = findByPrimaryKey(id);
9754    
9755                    Session session = null;
9756    
9757                    try {
9758                            session = openSession();
9759    
9760                            JournalArticle[] array = new JournalArticleImpl[3];
9761    
9762                            array[0] = filterGetByG_UT_PrevAndNext(session, journalArticle,
9763                                            groupId, urlTitle, orderByComparator, true);
9764    
9765                            array[1] = journalArticle;
9766    
9767                            array[2] = filterGetByG_UT_PrevAndNext(session, journalArticle,
9768                                            groupId, urlTitle, orderByComparator, false);
9769    
9770                            return array;
9771                    }
9772                    catch (Exception e) {
9773                            throw processException(e);
9774                    }
9775                    finally {
9776                            closeSession(session);
9777                    }
9778            }
9779    
9780            protected JournalArticle filterGetByG_UT_PrevAndNext(Session session,
9781                    JournalArticle journalArticle, long groupId, String urlTitle,
9782                    OrderByComparator orderByComparator, boolean previous) {
9783                    StringBundler query = null;
9784    
9785                    if (orderByComparator != null) {
9786                            query = new StringBundler(6 +
9787                                            (orderByComparator.getOrderByFields().length * 6));
9788                    }
9789                    else {
9790                            query = new StringBundler(3);
9791                    }
9792    
9793                    if (getDB().isSupportsInlineDistinct()) {
9794                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
9795                    }
9796                    else {
9797                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
9798                    }
9799    
9800                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
9801    
9802                    boolean bindUrlTitle = false;
9803    
9804                    if (urlTitle == null) {
9805                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
9806                    }
9807                    else if (urlTitle.equals(StringPool.BLANK)) {
9808                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
9809                    }
9810                    else {
9811                            bindUrlTitle = true;
9812    
9813                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
9814                    }
9815    
9816                    if (!getDB().isSupportsInlineDistinct()) {
9817                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
9818                    }
9819    
9820                    if (orderByComparator != null) {
9821                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9822    
9823                            if (orderByConditionFields.length > 0) {
9824                                    query.append(WHERE_AND);
9825                            }
9826    
9827                            for (int i = 0; i < orderByConditionFields.length; i++) {
9828                                    if (getDB().isSupportsInlineDistinct()) {
9829                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9830                                    }
9831                                    else {
9832                                            query.append(_ORDER_BY_ENTITY_TABLE);
9833                                    }
9834    
9835                                    query.append(orderByConditionFields[i]);
9836    
9837                                    if ((i + 1) < orderByConditionFields.length) {
9838                                            if (orderByComparator.isAscending() ^ previous) {
9839                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9840                                            }
9841                                            else {
9842                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9843                                            }
9844                                    }
9845                                    else {
9846                                            if (orderByComparator.isAscending() ^ previous) {
9847                                                    query.append(WHERE_GREATER_THAN);
9848                                            }
9849                                            else {
9850                                                    query.append(WHERE_LESSER_THAN);
9851                                            }
9852                                    }
9853                            }
9854    
9855                            query.append(ORDER_BY_CLAUSE);
9856    
9857                            String[] orderByFields = orderByComparator.getOrderByFields();
9858    
9859                            for (int i = 0; i < orderByFields.length; i++) {
9860                                    if (getDB().isSupportsInlineDistinct()) {
9861                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9862                                    }
9863                                    else {
9864                                            query.append(_ORDER_BY_ENTITY_TABLE);
9865                                    }
9866    
9867                                    query.append(orderByFields[i]);
9868    
9869                                    if ((i + 1) < orderByFields.length) {
9870                                            if (orderByComparator.isAscending() ^ previous) {
9871                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9872                                            }
9873                                            else {
9874                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9875                                            }
9876                                    }
9877                                    else {
9878                                            if (orderByComparator.isAscending() ^ previous) {
9879                                                    query.append(ORDER_BY_ASC);
9880                                            }
9881                                            else {
9882                                                    query.append(ORDER_BY_DESC);
9883                                            }
9884                                    }
9885                            }
9886                    }
9887                    else {
9888                            if (getDB().isSupportsInlineDistinct()) {
9889                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9890                            }
9891                            else {
9892                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
9893                            }
9894                    }
9895    
9896                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9897                                    JournalArticle.class.getName(),
9898                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9899    
9900                    SQLQuery q = session.createSQLQuery(sql);
9901    
9902                    q.setFirstResult(0);
9903                    q.setMaxResults(2);
9904    
9905                    if (getDB().isSupportsInlineDistinct()) {
9906                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
9907                    }
9908                    else {
9909                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
9910                    }
9911    
9912                    QueryPos qPos = QueryPos.getInstance(q);
9913    
9914                    qPos.add(groupId);
9915    
9916                    if (bindUrlTitle) {
9917                            qPos.add(urlTitle);
9918                    }
9919    
9920                    if (orderByComparator != null) {
9921                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
9922    
9923                            for (Object value : values) {
9924                                    qPos.add(value);
9925                            }
9926                    }
9927    
9928                    List<JournalArticle> list = q.list();
9929    
9930                    if (list.size() == 2) {
9931                            return list.get(1);
9932                    }
9933                    else {
9934                            return null;
9935                    }
9936            }
9937    
9938            /**
9939             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; from the database.
9940             *
9941             * @param groupId the group ID
9942             * @param urlTitle the url title
9943             * @throws SystemException if a system exception occurred
9944             */
9945            public void removeByG_UT(long groupId, String urlTitle)
9946                    throws SystemException {
9947                    for (JournalArticle journalArticle : findByG_UT(groupId, urlTitle,
9948                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
9949                            remove(journalArticle);
9950                    }
9951            }
9952    
9953            /**
9954             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63;.
9955             *
9956             * @param groupId the group ID
9957             * @param urlTitle the url title
9958             * @return the number of matching journal articles
9959             * @throws SystemException if a system exception occurred
9960             */
9961            public int countByG_UT(long groupId, String urlTitle)
9962                    throws SystemException {
9963                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_UT;
9964    
9965                    Object[] finderArgs = new Object[] { groupId, urlTitle };
9966    
9967                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
9968                                    this);
9969    
9970                    if (count == null) {
9971                            StringBundler query = new StringBundler(3);
9972    
9973                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
9974    
9975                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
9976    
9977                            boolean bindUrlTitle = false;
9978    
9979                            if (urlTitle == null) {
9980                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
9981                            }
9982                            else if (urlTitle.equals(StringPool.BLANK)) {
9983                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
9984                            }
9985                            else {
9986                                    bindUrlTitle = true;
9987    
9988                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
9989                            }
9990    
9991                            String sql = query.toString();
9992    
9993                            Session session = null;
9994    
9995                            try {
9996                                    session = openSession();
9997    
9998                                    Query q = session.createQuery(sql);
9999    
10000                                    QueryPos qPos = QueryPos.getInstance(q);
10001    
10002                                    qPos.add(groupId);
10003    
10004                                    if (bindUrlTitle) {
10005                                            qPos.add(urlTitle);
10006                                    }
10007    
10008                                    count = (Long)q.uniqueResult();
10009    
10010                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
10011                            }
10012                            catch (Exception e) {
10013                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10014    
10015                                    throw processException(e);
10016                            }
10017                            finally {
10018                                    closeSession(session);
10019                            }
10020                    }
10021    
10022                    return count.intValue();
10023            }
10024    
10025            /**
10026             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
10027             *
10028             * @param groupId the group ID
10029             * @param urlTitle the url title
10030             * @return the number of matching journal articles that the user has permission to view
10031             * @throws SystemException if a system exception occurred
10032             */
10033            public int filterCountByG_UT(long groupId, String urlTitle)
10034                    throws SystemException {
10035                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10036                            return countByG_UT(groupId, urlTitle);
10037                    }
10038    
10039                    StringBundler query = new StringBundler(3);
10040    
10041                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
10042    
10043                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
10044    
10045                    boolean bindUrlTitle = false;
10046    
10047                    if (urlTitle == null) {
10048                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
10049                    }
10050                    else if (urlTitle.equals(StringPool.BLANK)) {
10051                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
10052                    }
10053                    else {
10054                            bindUrlTitle = true;
10055    
10056                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
10057                    }
10058    
10059                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10060                                    JournalArticle.class.getName(),
10061                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10062    
10063                    Session session = null;
10064    
10065                    try {
10066                            session = openSession();
10067    
10068                            SQLQuery q = session.createSQLQuery(sql);
10069    
10070                            q.addScalar(COUNT_COLUMN_NAME,
10071                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
10072    
10073                            QueryPos qPos = QueryPos.getInstance(q);
10074    
10075                            qPos.add(groupId);
10076    
10077                            if (bindUrlTitle) {
10078                                    qPos.add(urlTitle);
10079                            }
10080    
10081                            Long count = (Long)q.uniqueResult();
10082    
10083                            return count.intValue();
10084                    }
10085                    catch (Exception e) {
10086                            throw processException(e);
10087                    }
10088                    finally {
10089                            closeSession(session);
10090                    }
10091            }
10092    
10093            private static final String _FINDER_COLUMN_G_UT_GROUPID_2 = "journalArticle.groupId = ? AND ";
10094            private static final String _FINDER_COLUMN_G_UT_URLTITLE_1 = "journalArticle.urlTitle IS NULL";
10095            private static final String _FINDER_COLUMN_G_UT_URLTITLE_2 = "journalArticle.urlTitle = ?";
10096            private static final String _FINDER_COLUMN_G_UT_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = '')";
10097            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
10098                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
10099                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
10100                            "findByG_S",
10101                            new String[] {
10102                                    Long.class.getName(), String.class.getName(),
10103                                    
10104                            Integer.class.getName(), Integer.class.getName(),
10105                                    OrderByComparator.class.getName()
10106                            });
10107            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
10108                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
10109                            JournalArticleImpl.class,
10110                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
10111                            new String[] { Long.class.getName(), String.class.getName() },
10112                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
10113                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK |
10114                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
10115                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
10116            public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
10117                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
10118                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
10119                            new String[] { Long.class.getName(), String.class.getName() });
10120    
10121            /**
10122             * Returns all the journal articles where groupId = &#63; and structureId = &#63;.
10123             *
10124             * @param groupId the group ID
10125             * @param structureId the structure ID
10126             * @return the matching journal articles
10127             * @throws SystemException if a system exception occurred
10128             */
10129            public List<JournalArticle> findByG_S(long groupId, String structureId)
10130                    throws SystemException {
10131                    return findByG_S(groupId, structureId, QueryUtil.ALL_POS,
10132                            QueryUtil.ALL_POS, null);
10133            }
10134    
10135            /**
10136             * Returns a range of all the journal articles where groupId = &#63; and structureId = &#63;.
10137             *
10138             * <p>
10139             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10140             * </p>
10141             *
10142             * @param groupId the group ID
10143             * @param structureId the structure ID
10144             * @param start the lower bound of the range of journal articles
10145             * @param end the upper bound of the range of journal articles (not inclusive)
10146             * @return the range of matching journal articles
10147             * @throws SystemException if a system exception occurred
10148             */
10149            public List<JournalArticle> findByG_S(long groupId, String structureId,
10150                    int start, int end) throws SystemException {
10151                    return findByG_S(groupId, structureId, start, end, null);
10152            }
10153    
10154            /**
10155             * Returns an ordered range of all the journal articles where groupId = &#63; and structureId = &#63;.
10156             *
10157             * <p>
10158             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10159             * </p>
10160             *
10161             * @param groupId the group ID
10162             * @param structureId the structure ID
10163             * @param start the lower bound of the range of journal articles
10164             * @param end the upper bound of the range of journal articles (not inclusive)
10165             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10166             * @return the ordered range of matching journal articles
10167             * @throws SystemException if a system exception occurred
10168             */
10169            public List<JournalArticle> findByG_S(long groupId, String structureId,
10170                    int start, int end, OrderByComparator orderByComparator)
10171                    throws SystemException {
10172                    boolean pagination = true;
10173                    FinderPath finderPath = null;
10174                    Object[] finderArgs = null;
10175    
10176                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10177                                    (orderByComparator == null)) {
10178                            pagination = false;
10179                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
10180                            finderArgs = new Object[] { groupId, structureId };
10181                    }
10182                    else {
10183                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
10184                            finderArgs = new Object[] {
10185                                            groupId, structureId,
10186                                            
10187                                            start, end, orderByComparator
10188                                    };
10189                    }
10190    
10191                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
10192                                    finderArgs, this);
10193    
10194                    if ((list != null) && !list.isEmpty()) {
10195                            for (JournalArticle journalArticle : list) {
10196                                    if ((groupId != journalArticle.getGroupId()) ||
10197                                                    !Validator.equals(structureId,
10198                                                            journalArticle.getStructureId())) {
10199                                            list = null;
10200    
10201                                            break;
10202                                    }
10203                            }
10204                    }
10205    
10206                    if (list == null) {
10207                            StringBundler query = null;
10208    
10209                            if (orderByComparator != null) {
10210                                    query = new StringBundler(4 +
10211                                                    (orderByComparator.getOrderByFields().length * 3));
10212                            }
10213                            else {
10214                                    query = new StringBundler(4);
10215                            }
10216    
10217                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10218    
10219                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
10220    
10221                            boolean bindStructureId = false;
10222    
10223                            if (structureId == null) {
10224                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
10225                            }
10226                            else if (structureId.equals(StringPool.BLANK)) {
10227                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
10228                            }
10229                            else {
10230                                    bindStructureId = true;
10231    
10232                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
10233                            }
10234    
10235                            if (orderByComparator != null) {
10236                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10237                                            orderByComparator);
10238                            }
10239                            else
10240                             if (pagination) {
10241                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10242                            }
10243    
10244                            String sql = query.toString();
10245    
10246                            Session session = null;
10247    
10248                            try {
10249                                    session = openSession();
10250    
10251                                    Query q = session.createQuery(sql);
10252    
10253                                    QueryPos qPos = QueryPos.getInstance(q);
10254    
10255                                    qPos.add(groupId);
10256    
10257                                    if (bindStructureId) {
10258                                            qPos.add(structureId);
10259                                    }
10260    
10261                                    if (!pagination) {
10262                                            list = (List<JournalArticle>)QueryUtil.list(q,
10263                                                            getDialect(), start, end, false);
10264    
10265                                            Collections.sort(list);
10266    
10267                                            list = new UnmodifiableList<JournalArticle>(list);
10268                                    }
10269                                    else {
10270                                            list = (List<JournalArticle>)QueryUtil.list(q,
10271                                                            getDialect(), start, end);
10272                                    }
10273    
10274                                    cacheResult(list);
10275    
10276                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
10277                            }
10278                            catch (Exception e) {
10279                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10280    
10281                                    throw processException(e);
10282                            }
10283                            finally {
10284                                    closeSession(session);
10285                            }
10286                    }
10287    
10288                    return list;
10289            }
10290    
10291            /**
10292             * Returns the first journal article in the ordered set where groupId = &#63; and structureId = &#63;.
10293             *
10294             * @param groupId the group ID
10295             * @param structureId the structure ID
10296             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10297             * @return the first matching journal article
10298             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10299             * @throws SystemException if a system exception occurred
10300             */
10301            public JournalArticle findByG_S_First(long groupId, String structureId,
10302                    OrderByComparator orderByComparator)
10303                    throws NoSuchArticleException, SystemException {
10304                    JournalArticle journalArticle = fetchByG_S_First(groupId, structureId,
10305                                    orderByComparator);
10306    
10307                    if (journalArticle != null) {
10308                            return journalArticle;
10309                    }
10310    
10311                    StringBundler msg = new StringBundler(6);
10312    
10313                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10314    
10315                    msg.append("groupId=");
10316                    msg.append(groupId);
10317    
10318                    msg.append(", structureId=");
10319                    msg.append(structureId);
10320    
10321                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10322    
10323                    throw new NoSuchArticleException(msg.toString());
10324            }
10325    
10326            /**
10327             * Returns the first journal article in the ordered set where groupId = &#63; and structureId = &#63;.
10328             *
10329             * @param groupId the group ID
10330             * @param structureId the structure ID
10331             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10332             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
10333             * @throws SystemException if a system exception occurred
10334             */
10335            public JournalArticle fetchByG_S_First(long groupId, String structureId,
10336                    OrderByComparator orderByComparator) throws SystemException {
10337                    List<JournalArticle> list = findByG_S(groupId, structureId, 0, 1,
10338                                    orderByComparator);
10339    
10340                    if (!list.isEmpty()) {
10341                            return list.get(0);
10342                    }
10343    
10344                    return null;
10345            }
10346    
10347            /**
10348             * Returns the last journal article in the ordered set where groupId = &#63; and structureId = &#63;.
10349             *
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 last matching journal article
10354             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10355             * @throws SystemException if a system exception occurred
10356             */
10357            public JournalArticle findByG_S_Last(long groupId, String structureId,
10358                    OrderByComparator orderByComparator)
10359                    throws NoSuchArticleException, SystemException {
10360                    JournalArticle journalArticle = fetchByG_S_Last(groupId, structureId,
10361                                    orderByComparator);
10362    
10363                    if (journalArticle != null) {
10364                            return journalArticle;
10365                    }
10366    
10367                    StringBundler msg = new StringBundler(6);
10368    
10369                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10370    
10371                    msg.append("groupId=");
10372                    msg.append(groupId);
10373    
10374                    msg.append(", structureId=");
10375                    msg.append(structureId);
10376    
10377                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10378    
10379                    throw new NoSuchArticleException(msg.toString());
10380            }
10381    
10382            /**
10383             * Returns the last journal article in the ordered set where groupId = &#63; and structureId = &#63;.
10384             *
10385             * @param groupId the group ID
10386             * @param structureId the structure ID
10387             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10388             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
10389             * @throws SystemException if a system exception occurred
10390             */
10391            public JournalArticle fetchByG_S_Last(long groupId, String structureId,
10392                    OrderByComparator orderByComparator) throws SystemException {
10393                    int count = countByG_S(groupId, structureId);
10394    
10395                    List<JournalArticle> list = findByG_S(groupId, structureId, count - 1,
10396                                    count, orderByComparator);
10397    
10398                    if (!list.isEmpty()) {
10399                            return list.get(0);
10400                    }
10401    
10402                    return null;
10403            }
10404    
10405            /**
10406             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and structureId = &#63;.
10407             *
10408             * @param id the primary key of the current journal article
10409             * @param groupId the group ID
10410             * @param structureId the structure ID
10411             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10412             * @return the previous, current, and next journal article
10413             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
10414             * @throws SystemException if a system exception occurred
10415             */
10416            public JournalArticle[] findByG_S_PrevAndNext(long id, long groupId,
10417                    String structureId, OrderByComparator orderByComparator)
10418                    throws NoSuchArticleException, SystemException {
10419                    JournalArticle journalArticle = findByPrimaryKey(id);
10420    
10421                    Session session = null;
10422    
10423                    try {
10424                            session = openSession();
10425    
10426                            JournalArticle[] array = new JournalArticleImpl[3];
10427    
10428                            array[0] = getByG_S_PrevAndNext(session, journalArticle, groupId,
10429                                            structureId, orderByComparator, true);
10430    
10431                            array[1] = journalArticle;
10432    
10433                            array[2] = getByG_S_PrevAndNext(session, journalArticle, groupId,
10434                                            structureId, orderByComparator, false);
10435    
10436                            return array;
10437                    }
10438                    catch (Exception e) {
10439                            throw processException(e);
10440                    }
10441                    finally {
10442                            closeSession(session);
10443                    }
10444            }
10445    
10446            protected JournalArticle getByG_S_PrevAndNext(Session session,
10447                    JournalArticle journalArticle, long groupId, String structureId,
10448                    OrderByComparator orderByComparator, boolean previous) {
10449                    StringBundler query = null;
10450    
10451                    if (orderByComparator != null) {
10452                            query = new StringBundler(6 +
10453                                            (orderByComparator.getOrderByFields().length * 6));
10454                    }
10455                    else {
10456                            query = new StringBundler(3);
10457                    }
10458    
10459                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10460    
10461                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
10462    
10463                    boolean bindStructureId = false;
10464    
10465                    if (structureId == null) {
10466                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
10467                    }
10468                    else if (structureId.equals(StringPool.BLANK)) {
10469                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
10470                    }
10471                    else {
10472                            bindStructureId = true;
10473    
10474                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
10475                    }
10476    
10477                    if (orderByComparator != null) {
10478                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10479    
10480                            if (orderByConditionFields.length > 0) {
10481                                    query.append(WHERE_AND);
10482                            }
10483    
10484                            for (int i = 0; i < orderByConditionFields.length; i++) {
10485                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10486                                    query.append(orderByConditionFields[i]);
10487    
10488                                    if ((i + 1) < orderByConditionFields.length) {
10489                                            if (orderByComparator.isAscending() ^ previous) {
10490                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10491                                            }
10492                                            else {
10493                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10494                                            }
10495                                    }
10496                                    else {
10497                                            if (orderByComparator.isAscending() ^ previous) {
10498                                                    query.append(WHERE_GREATER_THAN);
10499                                            }
10500                                            else {
10501                                                    query.append(WHERE_LESSER_THAN);
10502                                            }
10503                                    }
10504                            }
10505    
10506                            query.append(ORDER_BY_CLAUSE);
10507    
10508                            String[] orderByFields = orderByComparator.getOrderByFields();
10509    
10510                            for (int i = 0; i < orderByFields.length; i++) {
10511                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10512                                    query.append(orderByFields[i]);
10513    
10514                                    if ((i + 1) < orderByFields.length) {
10515                                            if (orderByComparator.isAscending() ^ previous) {
10516                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10517                                            }
10518                                            else {
10519                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10520                                            }
10521                                    }
10522                                    else {
10523                                            if (orderByComparator.isAscending() ^ previous) {
10524                                                    query.append(ORDER_BY_ASC);
10525                                            }
10526                                            else {
10527                                                    query.append(ORDER_BY_DESC);
10528                                            }
10529                                    }
10530                            }
10531                    }
10532                    else {
10533                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10534                    }
10535    
10536                    String sql = query.toString();
10537    
10538                    Query q = session.createQuery(sql);
10539    
10540                    q.setFirstResult(0);
10541                    q.setMaxResults(2);
10542    
10543                    QueryPos qPos = QueryPos.getInstance(q);
10544    
10545                    qPos.add(groupId);
10546    
10547                    if (bindStructureId) {
10548                            qPos.add(structureId);
10549                    }
10550    
10551                    if (orderByComparator != null) {
10552                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
10553    
10554                            for (Object value : values) {
10555                                    qPos.add(value);
10556                            }
10557                    }
10558    
10559                    List<JournalArticle> list = q.list();
10560    
10561                    if (list.size() == 2) {
10562                            return list.get(1);
10563                    }
10564                    else {
10565                            return null;
10566                    }
10567            }
10568    
10569            /**
10570             * Returns all the journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
10571             *
10572             * @param groupId the group ID
10573             * @param structureId the structure ID
10574             * @return the matching journal articles that the user has permission to view
10575             * @throws SystemException if a system exception occurred
10576             */
10577            public List<JournalArticle> filterFindByG_S(long groupId, String structureId)
10578                    throws SystemException {
10579                    return filterFindByG_S(groupId, structureId, QueryUtil.ALL_POS,
10580                            QueryUtil.ALL_POS, null);
10581            }
10582    
10583            /**
10584             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
10585             *
10586             * <p>
10587             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10588             * </p>
10589             *
10590             * @param groupId the group ID
10591             * @param structureId the structure ID
10592             * @param start the lower bound of the range of journal articles
10593             * @param end the upper bound of the range of journal articles (not inclusive)
10594             * @return the range of matching journal articles that the user has permission to view
10595             * @throws SystemException if a system exception occurred
10596             */
10597            public List<JournalArticle> filterFindByG_S(long groupId,
10598                    String structureId, int start, int end) throws SystemException {
10599                    return filterFindByG_S(groupId, structureId, start, end, null);
10600            }
10601    
10602            /**
10603             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and structureId = &#63;.
10604             *
10605             * <p>
10606             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10607             * </p>
10608             *
10609             * @param groupId the group ID
10610             * @param structureId the structure ID
10611             * @param start the lower bound of the range of journal articles
10612             * @param end the upper bound of the range of journal articles (not inclusive)
10613             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10614             * @return the ordered range of matching journal articles that the user has permission to view
10615             * @throws SystemException if a system exception occurred
10616             */
10617            public List<JournalArticle> filterFindByG_S(long groupId,
10618                    String structureId, int start, int end,
10619                    OrderByComparator orderByComparator) throws SystemException {
10620                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10621                            return findByG_S(groupId, structureId, start, end, orderByComparator);
10622                    }
10623    
10624                    StringBundler query = null;
10625    
10626                    if (orderByComparator != null) {
10627                            query = new StringBundler(4 +
10628                                            (orderByComparator.getOrderByFields().length * 3));
10629                    }
10630                    else {
10631                            query = new StringBundler(4);
10632                    }
10633    
10634                    if (getDB().isSupportsInlineDistinct()) {
10635                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
10636                    }
10637                    else {
10638                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
10639                    }
10640    
10641                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
10642    
10643                    boolean bindStructureId = false;
10644    
10645                    if (structureId == null) {
10646                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
10647                    }
10648                    else if (structureId.equals(StringPool.BLANK)) {
10649                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
10650                    }
10651                    else {
10652                            bindStructureId = true;
10653    
10654                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
10655                    }
10656    
10657                    if (!getDB().isSupportsInlineDistinct()) {
10658                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
10659                    }
10660    
10661                    if (orderByComparator != null) {
10662                            if (getDB().isSupportsInlineDistinct()) {
10663                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10664                                            orderByComparator);
10665                            }
10666                            else {
10667                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10668                                            orderByComparator);
10669                            }
10670                    }
10671                    else {
10672                            if (getDB().isSupportsInlineDistinct()) {
10673                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10674                            }
10675                            else {
10676                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
10677                            }
10678                    }
10679    
10680                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10681                                    JournalArticle.class.getName(),
10682                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10683    
10684                    Session session = null;
10685    
10686                    try {
10687                            session = openSession();
10688    
10689                            SQLQuery q = session.createSQLQuery(sql);
10690    
10691                            if (getDB().isSupportsInlineDistinct()) {
10692                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
10693                            }
10694                            else {
10695                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
10696                            }
10697    
10698                            QueryPos qPos = QueryPos.getInstance(q);
10699    
10700                            qPos.add(groupId);
10701    
10702                            if (bindStructureId) {
10703                                    qPos.add(structureId);
10704                            }
10705    
10706                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
10707                                    end);
10708                    }
10709                    catch (Exception e) {
10710                            throw processException(e);
10711                    }
10712                    finally {
10713                            closeSession(session);
10714                    }
10715            }
10716    
10717            /**
10718             * 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;.
10719             *
10720             * @param id the primary key of the current journal article
10721             * @param groupId the group ID
10722             * @param structureId the structure ID
10723             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10724             * @return the previous, current, and next journal article
10725             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
10726             * @throws SystemException if a system exception occurred
10727             */
10728            public JournalArticle[] filterFindByG_S_PrevAndNext(long id, long groupId,
10729                    String structureId, OrderByComparator orderByComparator)
10730                    throws NoSuchArticleException, SystemException {
10731                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10732                            return findByG_S_PrevAndNext(id, groupId, structureId,
10733                                    orderByComparator);
10734                    }
10735    
10736                    JournalArticle journalArticle = findByPrimaryKey(id);
10737    
10738                    Session session = null;
10739    
10740                    try {
10741                            session = openSession();
10742    
10743                            JournalArticle[] array = new JournalArticleImpl[3];
10744    
10745                            array[0] = filterGetByG_S_PrevAndNext(session, journalArticle,
10746                                            groupId, structureId, orderByComparator, true);
10747    
10748                            array[1] = journalArticle;
10749    
10750                            array[2] = filterGetByG_S_PrevAndNext(session, journalArticle,
10751                                            groupId, structureId, orderByComparator, false);
10752    
10753                            return array;
10754                    }
10755                    catch (Exception e) {
10756                            throw processException(e);
10757                    }
10758                    finally {
10759                            closeSession(session);
10760                    }
10761            }
10762    
10763            protected JournalArticle filterGetByG_S_PrevAndNext(Session session,
10764                    JournalArticle journalArticle, long groupId, String structureId,
10765                    OrderByComparator orderByComparator, boolean previous) {
10766                    StringBundler query = null;
10767    
10768                    if (orderByComparator != null) {
10769                            query = new StringBundler(6 +
10770                                            (orderByComparator.getOrderByFields().length * 6));
10771                    }
10772                    else {
10773                            query = new StringBundler(3);
10774                    }
10775    
10776                    if (getDB().isSupportsInlineDistinct()) {
10777                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
10778                    }
10779                    else {
10780                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
10781                    }
10782    
10783                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
10784    
10785                    boolean bindStructureId = false;
10786    
10787                    if (structureId == null) {
10788                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
10789                    }
10790                    else if (structureId.equals(StringPool.BLANK)) {
10791                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
10792                    }
10793                    else {
10794                            bindStructureId = true;
10795    
10796                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
10797                    }
10798    
10799                    if (!getDB().isSupportsInlineDistinct()) {
10800                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
10801                    }
10802    
10803                    if (orderByComparator != null) {
10804                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10805    
10806                            if (orderByConditionFields.length > 0) {
10807                                    query.append(WHERE_AND);
10808                            }
10809    
10810                            for (int i = 0; i < orderByConditionFields.length; i++) {
10811                                    if (getDB().isSupportsInlineDistinct()) {
10812                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10813                                    }
10814                                    else {
10815                                            query.append(_ORDER_BY_ENTITY_TABLE);
10816                                    }
10817    
10818                                    query.append(orderByConditionFields[i]);
10819    
10820                                    if ((i + 1) < orderByConditionFields.length) {
10821                                            if (orderByComparator.isAscending() ^ previous) {
10822                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10823                                            }
10824                                            else {
10825                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10826                                            }
10827                                    }
10828                                    else {
10829                                            if (orderByComparator.isAscending() ^ previous) {
10830                                                    query.append(WHERE_GREATER_THAN);
10831                                            }
10832                                            else {
10833                                                    query.append(WHERE_LESSER_THAN);
10834                                            }
10835                                    }
10836                            }
10837    
10838                            query.append(ORDER_BY_CLAUSE);
10839    
10840                            String[] orderByFields = orderByComparator.getOrderByFields();
10841    
10842                            for (int i = 0; i < orderByFields.length; i++) {
10843                                    if (getDB().isSupportsInlineDistinct()) {
10844                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10845                                    }
10846                                    else {
10847                                            query.append(_ORDER_BY_ENTITY_TABLE);
10848                                    }
10849    
10850                                    query.append(orderByFields[i]);
10851    
10852                                    if ((i + 1) < orderByFields.length) {
10853                                            if (orderByComparator.isAscending() ^ previous) {
10854                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10855                                            }
10856                                            else {
10857                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10858                                            }
10859                                    }
10860                                    else {
10861                                            if (orderByComparator.isAscending() ^ previous) {
10862                                                    query.append(ORDER_BY_ASC);
10863                                            }
10864                                            else {
10865                                                    query.append(ORDER_BY_DESC);
10866                                            }
10867                                    }
10868                            }
10869                    }
10870                    else {
10871                            if (getDB().isSupportsInlineDistinct()) {
10872                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10873                            }
10874                            else {
10875                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
10876                            }
10877                    }
10878    
10879                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10880                                    JournalArticle.class.getName(),
10881                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10882    
10883                    SQLQuery q = session.createSQLQuery(sql);
10884    
10885                    q.setFirstResult(0);
10886                    q.setMaxResults(2);
10887    
10888                    if (getDB().isSupportsInlineDistinct()) {
10889                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
10890                    }
10891                    else {
10892                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
10893                    }
10894    
10895                    QueryPos qPos = QueryPos.getInstance(q);
10896    
10897                    qPos.add(groupId);
10898    
10899                    if (bindStructureId) {
10900                            qPos.add(structureId);
10901                    }
10902    
10903                    if (orderByComparator != null) {
10904                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
10905    
10906                            for (Object value : values) {
10907                                    qPos.add(value);
10908                            }
10909                    }
10910    
10911                    List<JournalArticle> list = q.list();
10912    
10913                    if (list.size() == 2) {
10914                            return list.get(1);
10915                    }
10916                    else {
10917                            return null;
10918                    }
10919            }
10920    
10921            /**
10922             * Removes all the journal articles where groupId = &#63; and structureId = &#63; from the database.
10923             *
10924             * @param groupId the group ID
10925             * @param structureId the structure ID
10926             * @throws SystemException if a system exception occurred
10927             */
10928            public void removeByG_S(long groupId, String structureId)
10929                    throws SystemException {
10930                    for (JournalArticle journalArticle : findByG_S(groupId, structureId,
10931                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10932                            remove(journalArticle);
10933                    }
10934            }
10935    
10936            /**
10937             * Returns the number of journal articles where groupId = &#63; and structureId = &#63;.
10938             *
10939             * @param groupId the group ID
10940             * @param structureId the structure ID
10941             * @return the number of matching journal articles
10942             * @throws SystemException if a system exception occurred
10943             */
10944            public int countByG_S(long groupId, String structureId)
10945                    throws SystemException {
10946                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_S;
10947    
10948                    Object[] finderArgs = new Object[] { groupId, structureId };
10949    
10950                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
10951                                    this);
10952    
10953                    if (count == null) {
10954                            StringBundler query = new StringBundler(3);
10955    
10956                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
10957    
10958                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
10959    
10960                            boolean bindStructureId = false;
10961    
10962                            if (structureId == null) {
10963                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
10964                            }
10965                            else if (structureId.equals(StringPool.BLANK)) {
10966                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
10967                            }
10968                            else {
10969                                    bindStructureId = true;
10970    
10971                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
10972                            }
10973    
10974                            String sql = query.toString();
10975    
10976                            Session session = null;
10977    
10978                            try {
10979                                    session = openSession();
10980    
10981                                    Query q = session.createQuery(sql);
10982    
10983                                    QueryPos qPos = QueryPos.getInstance(q);
10984    
10985                                    qPos.add(groupId);
10986    
10987                                    if (bindStructureId) {
10988                                            qPos.add(structureId);
10989                                    }
10990    
10991                                    count = (Long)q.uniqueResult();
10992    
10993                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
10994                            }
10995                            catch (Exception e) {
10996                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10997    
10998                                    throw processException(e);
10999                            }
11000                            finally {
11001                                    closeSession(session);
11002                            }
11003                    }
11004    
11005                    return count.intValue();
11006            }
11007    
11008            /**
11009             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
11010             *
11011             * @param groupId the group ID
11012             * @param structureId the structure ID
11013             * @return the number of matching journal articles that the user has permission to view
11014             * @throws SystemException if a system exception occurred
11015             */
11016            public int filterCountByG_S(long groupId, String structureId)
11017                    throws SystemException {
11018                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11019                            return countByG_S(groupId, structureId);
11020                    }
11021    
11022                    StringBundler query = new StringBundler(3);
11023    
11024                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
11025    
11026                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
11027    
11028                    boolean bindStructureId = false;
11029    
11030                    if (structureId == null) {
11031                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
11032                    }
11033                    else if (structureId.equals(StringPool.BLANK)) {
11034                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
11035                    }
11036                    else {
11037                            bindStructureId = true;
11038    
11039                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
11040                    }
11041    
11042                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11043                                    JournalArticle.class.getName(),
11044                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11045    
11046                    Session session = null;
11047    
11048                    try {
11049                            session = openSession();
11050    
11051                            SQLQuery q = session.createSQLQuery(sql);
11052    
11053                            q.addScalar(COUNT_COLUMN_NAME,
11054                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11055    
11056                            QueryPos qPos = QueryPos.getInstance(q);
11057    
11058                            qPos.add(groupId);
11059    
11060                            if (bindStructureId) {
11061                                    qPos.add(structureId);
11062                            }
11063    
11064                            Long count = (Long)q.uniqueResult();
11065    
11066                            return count.intValue();
11067                    }
11068                    catch (Exception e) {
11069                            throw processException(e);
11070                    }
11071                    finally {
11072                            closeSession(session);
11073                    }
11074            }
11075    
11076            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
11077            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
11078            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
11079            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = '')";
11080            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
11081                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
11082                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
11083                            "findByG_T",
11084                            new String[] {
11085                                    Long.class.getName(), String.class.getName(),
11086                                    
11087                            Integer.class.getName(), Integer.class.getName(),
11088                                    OrderByComparator.class.getName()
11089                            });
11090            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
11091                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
11092                            JournalArticleImpl.class,
11093                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_T",
11094                            new String[] { Long.class.getName(), String.class.getName() },
11095                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
11096                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK |
11097                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
11098                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
11099            public static final FinderPath FINDER_PATH_COUNT_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
11100                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
11101                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_T",
11102                            new String[] { Long.class.getName(), String.class.getName() });
11103    
11104            /**
11105             * Returns all the journal articles where groupId = &#63; and templateId = &#63;.
11106             *
11107             * @param groupId the group ID
11108             * @param templateId the template ID
11109             * @return the matching journal articles
11110             * @throws SystemException if a system exception occurred
11111             */
11112            public List<JournalArticle> findByG_T(long groupId, String templateId)
11113                    throws SystemException {
11114                    return findByG_T(groupId, templateId, QueryUtil.ALL_POS,
11115                            QueryUtil.ALL_POS, null);
11116            }
11117    
11118            /**
11119             * Returns a range of all the journal articles where groupId = &#63; and templateId = &#63;.
11120             *
11121             * <p>
11122             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11123             * </p>
11124             *
11125             * @param groupId the group ID
11126             * @param templateId the template ID
11127             * @param start the lower bound of the range of journal articles
11128             * @param end the upper bound of the range of journal articles (not inclusive)
11129             * @return the range of matching journal articles
11130             * @throws SystemException if a system exception occurred
11131             */
11132            public List<JournalArticle> findByG_T(long groupId, String templateId,
11133                    int start, int end) throws SystemException {
11134                    return findByG_T(groupId, templateId, start, end, null);
11135            }
11136    
11137            /**
11138             * Returns an ordered range of all the journal articles where groupId = &#63; and templateId = &#63;.
11139             *
11140             * <p>
11141             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11142             * </p>
11143             *
11144             * @param groupId the group ID
11145             * @param templateId the template ID
11146             * @param start the lower bound of the range of journal articles
11147             * @param end the upper bound of the range of journal articles (not inclusive)
11148             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11149             * @return the ordered range of matching journal articles
11150             * @throws SystemException if a system exception occurred
11151             */
11152            public List<JournalArticle> findByG_T(long groupId, String templateId,
11153                    int start, int end, OrderByComparator orderByComparator)
11154                    throws SystemException {
11155                    boolean pagination = true;
11156                    FinderPath finderPath = null;
11157                    Object[] finderArgs = null;
11158    
11159                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11160                                    (orderByComparator == null)) {
11161                            pagination = false;
11162                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T;
11163                            finderArgs = new Object[] { groupId, templateId };
11164                    }
11165                    else {
11166                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_T;
11167                            finderArgs = new Object[] {
11168                                            groupId, templateId,
11169                                            
11170                                            start, end, orderByComparator
11171                                    };
11172                    }
11173    
11174                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
11175                                    finderArgs, this);
11176    
11177                    if ((list != null) && !list.isEmpty()) {
11178                            for (JournalArticle journalArticle : list) {
11179                                    if ((groupId != journalArticle.getGroupId()) ||
11180                                                    !Validator.equals(templateId,
11181                                                            journalArticle.getTemplateId())) {
11182                                            list = null;
11183    
11184                                            break;
11185                                    }
11186                            }
11187                    }
11188    
11189                    if (list == null) {
11190                            StringBundler query = null;
11191    
11192                            if (orderByComparator != null) {
11193                                    query = new StringBundler(4 +
11194                                                    (orderByComparator.getOrderByFields().length * 3));
11195                            }
11196                            else {
11197                                    query = new StringBundler(4);
11198                            }
11199    
11200                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11201    
11202                            query.append(_FINDER_COLUMN_G_T_GROUPID_2);
11203    
11204                            boolean bindTemplateId = false;
11205    
11206                            if (templateId == null) {
11207                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
11208                            }
11209                            else if (templateId.equals(StringPool.BLANK)) {
11210                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
11211                            }
11212                            else {
11213                                    bindTemplateId = true;
11214    
11215                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
11216                            }
11217    
11218                            if (orderByComparator != null) {
11219                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11220                                            orderByComparator);
11221                            }
11222                            else
11223                             if (pagination) {
11224                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11225                            }
11226    
11227                            String sql = query.toString();
11228    
11229                            Session session = null;
11230    
11231                            try {
11232                                    session = openSession();
11233    
11234                                    Query q = session.createQuery(sql);
11235    
11236                                    QueryPos qPos = QueryPos.getInstance(q);
11237    
11238                                    qPos.add(groupId);
11239    
11240                                    if (bindTemplateId) {
11241                                            qPos.add(templateId);
11242                                    }
11243    
11244                                    if (!pagination) {
11245                                            list = (List<JournalArticle>)QueryUtil.list(q,
11246                                                            getDialect(), start, end, false);
11247    
11248                                            Collections.sort(list);
11249    
11250                                            list = new UnmodifiableList<JournalArticle>(list);
11251                                    }
11252                                    else {
11253                                            list = (List<JournalArticle>)QueryUtil.list(q,
11254                                                            getDialect(), start, end);
11255                                    }
11256    
11257                                    cacheResult(list);
11258    
11259                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
11260                            }
11261                            catch (Exception e) {
11262                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11263    
11264                                    throw processException(e);
11265                            }
11266                            finally {
11267                                    closeSession(session);
11268                            }
11269                    }
11270    
11271                    return list;
11272            }
11273    
11274            /**
11275             * Returns the first journal article in the ordered set where groupId = &#63; and templateId = &#63;.
11276             *
11277             * @param groupId the group ID
11278             * @param templateId the template ID
11279             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11280             * @return the first matching journal article
11281             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11282             * @throws SystemException if a system exception occurred
11283             */
11284            public JournalArticle findByG_T_First(long groupId, String templateId,
11285                    OrderByComparator orderByComparator)
11286                    throws NoSuchArticleException, SystemException {
11287                    JournalArticle journalArticle = fetchByG_T_First(groupId, templateId,
11288                                    orderByComparator);
11289    
11290                    if (journalArticle != null) {
11291                            return journalArticle;
11292                    }
11293    
11294                    StringBundler msg = new StringBundler(6);
11295    
11296                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11297    
11298                    msg.append("groupId=");
11299                    msg.append(groupId);
11300    
11301                    msg.append(", templateId=");
11302                    msg.append(templateId);
11303    
11304                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11305    
11306                    throw new NoSuchArticleException(msg.toString());
11307            }
11308    
11309            /**
11310             * Returns the first journal article in the ordered set where groupId = &#63; and templateId = &#63;.
11311             *
11312             * @param groupId the group ID
11313             * @param templateId the template ID
11314             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11315             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
11316             * @throws SystemException if a system exception occurred
11317             */
11318            public JournalArticle fetchByG_T_First(long groupId, String templateId,
11319                    OrderByComparator orderByComparator) throws SystemException {
11320                    List<JournalArticle> list = findByG_T(groupId, templateId, 0, 1,
11321                                    orderByComparator);
11322    
11323                    if (!list.isEmpty()) {
11324                            return list.get(0);
11325                    }
11326    
11327                    return null;
11328            }
11329    
11330            /**
11331             * Returns the last journal article in the ordered set where groupId = &#63; and templateId = &#63;.
11332             *
11333             * @param groupId the group ID
11334             * @param templateId the template ID
11335             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11336             * @return the last matching journal article
11337             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11338             * @throws SystemException if a system exception occurred
11339             */
11340            public JournalArticle findByG_T_Last(long groupId, String templateId,
11341                    OrderByComparator orderByComparator)
11342                    throws NoSuchArticleException, SystemException {
11343                    JournalArticle journalArticle = fetchByG_T_Last(groupId, templateId,
11344                                    orderByComparator);
11345    
11346                    if (journalArticle != null) {
11347                            return journalArticle;
11348                    }
11349    
11350                    StringBundler msg = new StringBundler(6);
11351    
11352                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11353    
11354                    msg.append("groupId=");
11355                    msg.append(groupId);
11356    
11357                    msg.append(", templateId=");
11358                    msg.append(templateId);
11359    
11360                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11361    
11362                    throw new NoSuchArticleException(msg.toString());
11363            }
11364    
11365            /**
11366             * Returns the last journal article in the ordered set where groupId = &#63; and templateId = &#63;.
11367             *
11368             * @param groupId the group ID
11369             * @param templateId the template ID
11370             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11371             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
11372             * @throws SystemException if a system exception occurred
11373             */
11374            public JournalArticle fetchByG_T_Last(long groupId, String templateId,
11375                    OrderByComparator orderByComparator) throws SystemException {
11376                    int count = countByG_T(groupId, templateId);
11377    
11378                    List<JournalArticle> list = findByG_T(groupId, templateId, count - 1,
11379                                    count, orderByComparator);
11380    
11381                    if (!list.isEmpty()) {
11382                            return list.get(0);
11383                    }
11384    
11385                    return null;
11386            }
11387    
11388            /**
11389             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and templateId = &#63;.
11390             *
11391             * @param id the primary key of the current journal article
11392             * @param groupId the group ID
11393             * @param templateId the template ID
11394             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11395             * @return the previous, current, and next journal article
11396             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
11397             * @throws SystemException if a system exception occurred
11398             */
11399            public JournalArticle[] findByG_T_PrevAndNext(long id, long groupId,
11400                    String templateId, OrderByComparator orderByComparator)
11401                    throws NoSuchArticleException, SystemException {
11402                    JournalArticle journalArticle = findByPrimaryKey(id);
11403    
11404                    Session session = null;
11405    
11406                    try {
11407                            session = openSession();
11408    
11409                            JournalArticle[] array = new JournalArticleImpl[3];
11410    
11411                            array[0] = getByG_T_PrevAndNext(session, journalArticle, groupId,
11412                                            templateId, orderByComparator, true);
11413    
11414                            array[1] = journalArticle;
11415    
11416                            array[2] = getByG_T_PrevAndNext(session, journalArticle, groupId,
11417                                            templateId, orderByComparator, false);
11418    
11419                            return array;
11420                    }
11421                    catch (Exception e) {
11422                            throw processException(e);
11423                    }
11424                    finally {
11425                            closeSession(session);
11426                    }
11427            }
11428    
11429            protected JournalArticle getByG_T_PrevAndNext(Session session,
11430                    JournalArticle journalArticle, long groupId, String templateId,
11431                    OrderByComparator orderByComparator, boolean previous) {
11432                    StringBundler query = null;
11433    
11434                    if (orderByComparator != null) {
11435                            query = new StringBundler(6 +
11436                                            (orderByComparator.getOrderByFields().length * 6));
11437                    }
11438                    else {
11439                            query = new StringBundler(3);
11440                    }
11441    
11442                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11443    
11444                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
11445    
11446                    boolean bindTemplateId = false;
11447    
11448                    if (templateId == null) {
11449                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
11450                    }
11451                    else if (templateId.equals(StringPool.BLANK)) {
11452                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
11453                    }
11454                    else {
11455                            bindTemplateId = true;
11456    
11457                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
11458                    }
11459    
11460                    if (orderByComparator != null) {
11461                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11462    
11463                            if (orderByConditionFields.length > 0) {
11464                                    query.append(WHERE_AND);
11465                            }
11466    
11467                            for (int i = 0; i < orderByConditionFields.length; i++) {
11468                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11469                                    query.append(orderByConditionFields[i]);
11470    
11471                                    if ((i + 1) < orderByConditionFields.length) {
11472                                            if (orderByComparator.isAscending() ^ previous) {
11473                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11474                                            }
11475                                            else {
11476                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11477                                            }
11478                                    }
11479                                    else {
11480                                            if (orderByComparator.isAscending() ^ previous) {
11481                                                    query.append(WHERE_GREATER_THAN);
11482                                            }
11483                                            else {
11484                                                    query.append(WHERE_LESSER_THAN);
11485                                            }
11486                                    }
11487                            }
11488    
11489                            query.append(ORDER_BY_CLAUSE);
11490    
11491                            String[] orderByFields = orderByComparator.getOrderByFields();
11492    
11493                            for (int i = 0; i < orderByFields.length; i++) {
11494                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11495                                    query.append(orderByFields[i]);
11496    
11497                                    if ((i + 1) < orderByFields.length) {
11498                                            if (orderByComparator.isAscending() ^ previous) {
11499                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11500                                            }
11501                                            else {
11502                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11503                                            }
11504                                    }
11505                                    else {
11506                                            if (orderByComparator.isAscending() ^ previous) {
11507                                                    query.append(ORDER_BY_ASC);
11508                                            }
11509                                            else {
11510                                                    query.append(ORDER_BY_DESC);
11511                                            }
11512                                    }
11513                            }
11514                    }
11515                    else {
11516                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11517                    }
11518    
11519                    String sql = query.toString();
11520    
11521                    Query q = session.createQuery(sql);
11522    
11523                    q.setFirstResult(0);
11524                    q.setMaxResults(2);
11525    
11526                    QueryPos qPos = QueryPos.getInstance(q);
11527    
11528                    qPos.add(groupId);
11529    
11530                    if (bindTemplateId) {
11531                            qPos.add(templateId);
11532                    }
11533    
11534                    if (orderByComparator != null) {
11535                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
11536    
11537                            for (Object value : values) {
11538                                    qPos.add(value);
11539                            }
11540                    }
11541    
11542                    List<JournalArticle> list = q.list();
11543    
11544                    if (list.size() == 2) {
11545                            return list.get(1);
11546                    }
11547                    else {
11548                            return null;
11549                    }
11550            }
11551    
11552            /**
11553             * Returns all the journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
11554             *
11555             * @param groupId the group ID
11556             * @param templateId the template ID
11557             * @return the matching journal articles that the user has permission to view
11558             * @throws SystemException if a system exception occurred
11559             */
11560            public List<JournalArticle> filterFindByG_T(long groupId, String templateId)
11561                    throws SystemException {
11562                    return filterFindByG_T(groupId, templateId, QueryUtil.ALL_POS,
11563                            QueryUtil.ALL_POS, null);
11564            }
11565    
11566            /**
11567             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
11568             *
11569             * <p>
11570             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11571             * </p>
11572             *
11573             * @param groupId the group ID
11574             * @param templateId the template ID
11575             * @param start the lower bound of the range of journal articles
11576             * @param end the upper bound of the range of journal articles (not inclusive)
11577             * @return the range of matching journal articles that the user has permission to view
11578             * @throws SystemException if a system exception occurred
11579             */
11580            public List<JournalArticle> filterFindByG_T(long groupId,
11581                    String templateId, int start, int end) throws SystemException {
11582                    return filterFindByG_T(groupId, templateId, start, end, null);
11583            }
11584    
11585            /**
11586             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and templateId = &#63;.
11587             *
11588             * <p>
11589             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11590             * </p>
11591             *
11592             * @param groupId the group ID
11593             * @param templateId the template ID
11594             * @param start the lower bound of the range of journal articles
11595             * @param end the upper bound of the range of journal articles (not inclusive)
11596             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11597             * @return the ordered range of matching journal articles that the user has permission to view
11598             * @throws SystemException if a system exception occurred
11599             */
11600            public List<JournalArticle> filterFindByG_T(long groupId,
11601                    String templateId, int start, int end,
11602                    OrderByComparator orderByComparator) throws SystemException {
11603                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11604                            return findByG_T(groupId, templateId, start, end, orderByComparator);
11605                    }
11606    
11607                    StringBundler query = null;
11608    
11609                    if (orderByComparator != null) {
11610                            query = new StringBundler(4 +
11611                                            (orderByComparator.getOrderByFields().length * 3));
11612                    }
11613                    else {
11614                            query = new StringBundler(4);
11615                    }
11616    
11617                    if (getDB().isSupportsInlineDistinct()) {
11618                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
11619                    }
11620                    else {
11621                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
11622                    }
11623    
11624                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
11625    
11626                    boolean bindTemplateId = false;
11627    
11628                    if (templateId == null) {
11629                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
11630                    }
11631                    else if (templateId.equals(StringPool.BLANK)) {
11632                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
11633                    }
11634                    else {
11635                            bindTemplateId = true;
11636    
11637                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
11638                    }
11639    
11640                    if (!getDB().isSupportsInlineDistinct()) {
11641                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
11642                    }
11643    
11644                    if (orderByComparator != null) {
11645                            if (getDB().isSupportsInlineDistinct()) {
11646                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11647                                            orderByComparator);
11648                            }
11649                            else {
11650                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11651                                            orderByComparator);
11652                            }
11653                    }
11654                    else {
11655                            if (getDB().isSupportsInlineDistinct()) {
11656                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11657                            }
11658                            else {
11659                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
11660                            }
11661                    }
11662    
11663                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11664                                    JournalArticle.class.getName(),
11665                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11666    
11667                    Session session = null;
11668    
11669                    try {
11670                            session = openSession();
11671    
11672                            SQLQuery q = session.createSQLQuery(sql);
11673    
11674                            if (getDB().isSupportsInlineDistinct()) {
11675                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
11676                            }
11677                            else {
11678                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
11679                            }
11680    
11681                            QueryPos qPos = QueryPos.getInstance(q);
11682    
11683                            qPos.add(groupId);
11684    
11685                            if (bindTemplateId) {
11686                                    qPos.add(templateId);
11687                            }
11688    
11689                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
11690                                    end);
11691                    }
11692                    catch (Exception e) {
11693                            throw processException(e);
11694                    }
11695                    finally {
11696                            closeSession(session);
11697                    }
11698            }
11699    
11700            /**
11701             * 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;.
11702             *
11703             * @param id the primary key of the current journal article
11704             * @param groupId the group ID
11705             * @param templateId the template ID
11706             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11707             * @return the previous, current, and next journal article
11708             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
11709             * @throws SystemException if a system exception occurred
11710             */
11711            public JournalArticle[] filterFindByG_T_PrevAndNext(long id, long groupId,
11712                    String templateId, OrderByComparator orderByComparator)
11713                    throws NoSuchArticleException, SystemException {
11714                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11715                            return findByG_T_PrevAndNext(id, groupId, templateId,
11716                                    orderByComparator);
11717                    }
11718    
11719                    JournalArticle journalArticle = findByPrimaryKey(id);
11720    
11721                    Session session = null;
11722    
11723                    try {
11724                            session = openSession();
11725    
11726                            JournalArticle[] array = new JournalArticleImpl[3];
11727    
11728                            array[0] = filterGetByG_T_PrevAndNext(session, journalArticle,
11729                                            groupId, templateId, orderByComparator, true);
11730    
11731                            array[1] = journalArticle;
11732    
11733                            array[2] = filterGetByG_T_PrevAndNext(session, journalArticle,
11734                                            groupId, templateId, orderByComparator, false);
11735    
11736                            return array;
11737                    }
11738                    catch (Exception e) {
11739                            throw processException(e);
11740                    }
11741                    finally {
11742                            closeSession(session);
11743                    }
11744            }
11745    
11746            protected JournalArticle filterGetByG_T_PrevAndNext(Session session,
11747                    JournalArticle journalArticle, long groupId, String templateId,
11748                    OrderByComparator orderByComparator, boolean previous) {
11749                    StringBundler query = null;
11750    
11751                    if (orderByComparator != null) {
11752                            query = new StringBundler(6 +
11753                                            (orderByComparator.getOrderByFields().length * 6));
11754                    }
11755                    else {
11756                            query = new StringBundler(3);
11757                    }
11758    
11759                    if (getDB().isSupportsInlineDistinct()) {
11760                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
11761                    }
11762                    else {
11763                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
11764                    }
11765    
11766                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
11767    
11768                    boolean bindTemplateId = false;
11769    
11770                    if (templateId == null) {
11771                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
11772                    }
11773                    else if (templateId.equals(StringPool.BLANK)) {
11774                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
11775                    }
11776                    else {
11777                            bindTemplateId = true;
11778    
11779                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
11780                    }
11781    
11782                    if (!getDB().isSupportsInlineDistinct()) {
11783                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
11784                    }
11785    
11786                    if (orderByComparator != null) {
11787                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11788    
11789                            if (orderByConditionFields.length > 0) {
11790                                    query.append(WHERE_AND);
11791                            }
11792    
11793                            for (int i = 0; i < orderByConditionFields.length; i++) {
11794                                    if (getDB().isSupportsInlineDistinct()) {
11795                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11796                                    }
11797                                    else {
11798                                            query.append(_ORDER_BY_ENTITY_TABLE);
11799                                    }
11800    
11801                                    query.append(orderByConditionFields[i]);
11802    
11803                                    if ((i + 1) < orderByConditionFields.length) {
11804                                            if (orderByComparator.isAscending() ^ previous) {
11805                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11806                                            }
11807                                            else {
11808                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11809                                            }
11810                                    }
11811                                    else {
11812                                            if (orderByComparator.isAscending() ^ previous) {
11813                                                    query.append(WHERE_GREATER_THAN);
11814                                            }
11815                                            else {
11816                                                    query.append(WHERE_LESSER_THAN);
11817                                            }
11818                                    }
11819                            }
11820    
11821                            query.append(ORDER_BY_CLAUSE);
11822    
11823                            String[] orderByFields = orderByComparator.getOrderByFields();
11824    
11825                            for (int i = 0; i < orderByFields.length; i++) {
11826                                    if (getDB().isSupportsInlineDistinct()) {
11827                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11828                                    }
11829                                    else {
11830                                            query.append(_ORDER_BY_ENTITY_TABLE);
11831                                    }
11832    
11833                                    query.append(orderByFields[i]);
11834    
11835                                    if ((i + 1) < orderByFields.length) {
11836                                            if (orderByComparator.isAscending() ^ previous) {
11837                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11838                                            }
11839                                            else {
11840                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11841                                            }
11842                                    }
11843                                    else {
11844                                            if (orderByComparator.isAscending() ^ previous) {
11845                                                    query.append(ORDER_BY_ASC);
11846                                            }
11847                                            else {
11848                                                    query.append(ORDER_BY_DESC);
11849                                            }
11850                                    }
11851                            }
11852                    }
11853                    else {
11854                            if (getDB().isSupportsInlineDistinct()) {
11855                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11856                            }
11857                            else {
11858                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
11859                            }
11860                    }
11861    
11862                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11863                                    JournalArticle.class.getName(),
11864                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11865    
11866                    SQLQuery q = session.createSQLQuery(sql);
11867    
11868                    q.setFirstResult(0);
11869                    q.setMaxResults(2);
11870    
11871                    if (getDB().isSupportsInlineDistinct()) {
11872                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
11873                    }
11874                    else {
11875                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
11876                    }
11877    
11878                    QueryPos qPos = QueryPos.getInstance(q);
11879    
11880                    qPos.add(groupId);
11881    
11882                    if (bindTemplateId) {
11883                            qPos.add(templateId);
11884                    }
11885    
11886                    if (orderByComparator != null) {
11887                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
11888    
11889                            for (Object value : values) {
11890                                    qPos.add(value);
11891                            }
11892                    }
11893    
11894                    List<JournalArticle> list = q.list();
11895    
11896                    if (list.size() == 2) {
11897                            return list.get(1);
11898                    }
11899                    else {
11900                            return null;
11901                    }
11902            }
11903    
11904            /**
11905             * Removes all the journal articles where groupId = &#63; and templateId = &#63; from the database.
11906             *
11907             * @param groupId the group ID
11908             * @param templateId the template ID
11909             * @throws SystemException if a system exception occurred
11910             */
11911            public void removeByG_T(long groupId, String templateId)
11912                    throws SystemException {
11913                    for (JournalArticle journalArticle : findByG_T(groupId, templateId,
11914                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
11915                            remove(journalArticle);
11916                    }
11917            }
11918    
11919            /**
11920             * Returns the number of journal articles where groupId = &#63; and templateId = &#63;.
11921             *
11922             * @param groupId the group ID
11923             * @param templateId the template ID
11924             * @return the number of matching journal articles
11925             * @throws SystemException if a system exception occurred
11926             */
11927            public int countByG_T(long groupId, String templateId)
11928                    throws SystemException {
11929                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_T;
11930    
11931                    Object[] finderArgs = new Object[] { groupId, templateId };
11932    
11933                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
11934                                    this);
11935    
11936                    if (count == null) {
11937                            StringBundler query = new StringBundler(3);
11938    
11939                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
11940    
11941                            query.append(_FINDER_COLUMN_G_T_GROUPID_2);
11942    
11943                            boolean bindTemplateId = false;
11944    
11945                            if (templateId == null) {
11946                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
11947                            }
11948                            else if (templateId.equals(StringPool.BLANK)) {
11949                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
11950                            }
11951                            else {
11952                                    bindTemplateId = true;
11953    
11954                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
11955                            }
11956    
11957                            String sql = query.toString();
11958    
11959                            Session session = null;
11960    
11961                            try {
11962                                    session = openSession();
11963    
11964                                    Query q = session.createQuery(sql);
11965    
11966                                    QueryPos qPos = QueryPos.getInstance(q);
11967    
11968                                    qPos.add(groupId);
11969    
11970                                    if (bindTemplateId) {
11971                                            qPos.add(templateId);
11972                                    }
11973    
11974                                    count = (Long)q.uniqueResult();
11975    
11976                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
11977                            }
11978                            catch (Exception e) {
11979                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11980    
11981                                    throw processException(e);
11982                            }
11983                            finally {
11984                                    closeSession(session);
11985                            }
11986                    }
11987    
11988                    return count.intValue();
11989            }
11990    
11991            /**
11992             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
11993             *
11994             * @param groupId the group ID
11995             * @param templateId the template ID
11996             * @return the number of matching journal articles that the user has permission to view
11997             * @throws SystemException if a system exception occurred
11998             */
11999            public int filterCountByG_T(long groupId, String templateId)
12000                    throws SystemException {
12001                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12002                            return countByG_T(groupId, templateId);
12003                    }
12004    
12005                    StringBundler query = new StringBundler(3);
12006    
12007                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
12008    
12009                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
12010    
12011                    boolean bindTemplateId = false;
12012    
12013                    if (templateId == null) {
12014                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
12015                    }
12016                    else if (templateId.equals(StringPool.BLANK)) {
12017                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
12018                    }
12019                    else {
12020                            bindTemplateId = true;
12021    
12022                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
12023                    }
12024    
12025                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12026                                    JournalArticle.class.getName(),
12027                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12028    
12029                    Session session = null;
12030    
12031                    try {
12032                            session = openSession();
12033    
12034                            SQLQuery q = session.createSQLQuery(sql);
12035    
12036                            q.addScalar(COUNT_COLUMN_NAME,
12037                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
12038    
12039                            QueryPos qPos = QueryPos.getInstance(q);
12040    
12041                            qPos.add(groupId);
12042    
12043                            if (bindTemplateId) {
12044                                    qPos.add(templateId);
12045                            }
12046    
12047                            Long count = (Long)q.uniqueResult();
12048    
12049                            return count.intValue();
12050                    }
12051                    catch (Exception e) {
12052                            throw processException(e);
12053                    }
12054                    finally {
12055                            closeSession(session);
12056                    }
12057            }
12058    
12059            private static final String _FINDER_COLUMN_G_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
12060            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
12061            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
12062            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = '')";
12063            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
12064                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
12065                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
12066                            "findByG_L",
12067                            new String[] {
12068                                    Long.class.getName(), String.class.getName(),
12069                                    
12070                            Integer.class.getName(), Integer.class.getName(),
12071                                    OrderByComparator.class.getName()
12072                            });
12073            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
12074                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
12075                            JournalArticleImpl.class,
12076                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_L",
12077                            new String[] { Long.class.getName(), String.class.getName() },
12078                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
12079                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK |
12080                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
12081                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
12082            public static final FinderPath FINDER_PATH_COUNT_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
12083                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
12084                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_L",
12085                            new String[] { Long.class.getName(), String.class.getName() });
12086    
12087            /**
12088             * Returns all the journal articles where groupId = &#63; and layoutUuid = &#63;.
12089             *
12090             * @param groupId the group ID
12091             * @param layoutUuid the layout uuid
12092             * @return the matching journal articles
12093             * @throws SystemException if a system exception occurred
12094             */
12095            public List<JournalArticle> findByG_L(long groupId, String layoutUuid)
12096                    throws SystemException {
12097                    return findByG_L(groupId, layoutUuid, QueryUtil.ALL_POS,
12098                            QueryUtil.ALL_POS, null);
12099            }
12100    
12101            /**
12102             * Returns a range of all the journal articles where groupId = &#63; and layoutUuid = &#63;.
12103             *
12104             * <p>
12105             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12106             * </p>
12107             *
12108             * @param groupId the group ID
12109             * @param layoutUuid the layout uuid
12110             * @param start the lower bound of the range of journal articles
12111             * @param end the upper bound of the range of journal articles (not inclusive)
12112             * @return the range of matching journal articles
12113             * @throws SystemException if a system exception occurred
12114             */
12115            public List<JournalArticle> findByG_L(long groupId, String layoutUuid,
12116                    int start, int end) throws SystemException {
12117                    return findByG_L(groupId, layoutUuid, start, end, null);
12118            }
12119    
12120            /**
12121             * Returns an ordered range of all the journal articles where groupId = &#63; and layoutUuid = &#63;.
12122             *
12123             * <p>
12124             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12125             * </p>
12126             *
12127             * @param groupId the group ID
12128             * @param layoutUuid the layout uuid
12129             * @param start the lower bound of the range of journal articles
12130             * @param end the upper bound of the range of journal articles (not inclusive)
12131             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12132             * @return the ordered range of matching journal articles
12133             * @throws SystemException if a system exception occurred
12134             */
12135            public List<JournalArticle> findByG_L(long groupId, String layoutUuid,
12136                    int start, int end, OrderByComparator orderByComparator)
12137                    throws SystemException {
12138                    boolean pagination = true;
12139                    FinderPath finderPath = null;
12140                    Object[] finderArgs = null;
12141    
12142                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12143                                    (orderByComparator == null)) {
12144                            pagination = false;
12145                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L;
12146                            finderArgs = new Object[] { groupId, layoutUuid };
12147                    }
12148                    else {
12149                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_L;
12150                            finderArgs = new Object[] {
12151                                            groupId, layoutUuid,
12152                                            
12153                                            start, end, orderByComparator
12154                                    };
12155                    }
12156    
12157                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
12158                                    finderArgs, this);
12159    
12160                    if ((list != null) && !list.isEmpty()) {
12161                            for (JournalArticle journalArticle : list) {
12162                                    if ((groupId != journalArticle.getGroupId()) ||
12163                                                    !Validator.equals(layoutUuid,
12164                                                            journalArticle.getLayoutUuid())) {
12165                                            list = null;
12166    
12167                                            break;
12168                                    }
12169                            }
12170                    }
12171    
12172                    if (list == null) {
12173                            StringBundler query = null;
12174    
12175                            if (orderByComparator != null) {
12176                                    query = new StringBundler(4 +
12177                                                    (orderByComparator.getOrderByFields().length * 3));
12178                            }
12179                            else {
12180                                    query = new StringBundler(4);
12181                            }
12182    
12183                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12184    
12185                            query.append(_FINDER_COLUMN_G_L_GROUPID_2);
12186    
12187                            boolean bindLayoutUuid = false;
12188    
12189                            if (layoutUuid == null) {
12190                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
12191                            }
12192                            else if (layoutUuid.equals(StringPool.BLANK)) {
12193                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
12194                            }
12195                            else {
12196                                    bindLayoutUuid = true;
12197    
12198                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
12199                            }
12200    
12201                            if (orderByComparator != null) {
12202                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12203                                            orderByComparator);
12204                            }
12205                            else
12206                             if (pagination) {
12207                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12208                            }
12209    
12210                            String sql = query.toString();
12211    
12212                            Session session = null;
12213    
12214                            try {
12215                                    session = openSession();
12216    
12217                                    Query q = session.createQuery(sql);
12218    
12219                                    QueryPos qPos = QueryPos.getInstance(q);
12220    
12221                                    qPos.add(groupId);
12222    
12223                                    if (bindLayoutUuid) {
12224                                            qPos.add(layoutUuid);
12225                                    }
12226    
12227                                    if (!pagination) {
12228                                            list = (List<JournalArticle>)QueryUtil.list(q,
12229                                                            getDialect(), start, end, false);
12230    
12231                                            Collections.sort(list);
12232    
12233                                            list = new UnmodifiableList<JournalArticle>(list);
12234                                    }
12235                                    else {
12236                                            list = (List<JournalArticle>)QueryUtil.list(q,
12237                                                            getDialect(), start, end);
12238                                    }
12239    
12240                                    cacheResult(list);
12241    
12242                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
12243                            }
12244                            catch (Exception e) {
12245                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12246    
12247                                    throw processException(e);
12248                            }
12249                            finally {
12250                                    closeSession(session);
12251                            }
12252                    }
12253    
12254                    return list;
12255            }
12256    
12257            /**
12258             * Returns the first journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
12259             *
12260             * @param groupId the group ID
12261             * @param layoutUuid the layout uuid
12262             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12263             * @return the first matching journal article
12264             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12265             * @throws SystemException if a system exception occurred
12266             */
12267            public JournalArticle findByG_L_First(long groupId, String layoutUuid,
12268                    OrderByComparator orderByComparator)
12269                    throws NoSuchArticleException, SystemException {
12270                    JournalArticle journalArticle = fetchByG_L_First(groupId, layoutUuid,
12271                                    orderByComparator);
12272    
12273                    if (journalArticle != null) {
12274                            return journalArticle;
12275                    }
12276    
12277                    StringBundler msg = new StringBundler(6);
12278    
12279                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12280    
12281                    msg.append("groupId=");
12282                    msg.append(groupId);
12283    
12284                    msg.append(", layoutUuid=");
12285                    msg.append(layoutUuid);
12286    
12287                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12288    
12289                    throw new NoSuchArticleException(msg.toString());
12290            }
12291    
12292            /**
12293             * Returns the first journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
12294             *
12295             * @param groupId the group ID
12296             * @param layoutUuid the layout uuid
12297             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12298             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
12299             * @throws SystemException if a system exception occurred
12300             */
12301            public JournalArticle fetchByG_L_First(long groupId, String layoutUuid,
12302                    OrderByComparator orderByComparator) throws SystemException {
12303                    List<JournalArticle> list = findByG_L(groupId, layoutUuid, 0, 1,
12304                                    orderByComparator);
12305    
12306                    if (!list.isEmpty()) {
12307                            return list.get(0);
12308                    }
12309    
12310                    return null;
12311            }
12312    
12313            /**
12314             * Returns the last journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
12315             *
12316             * @param groupId the group ID
12317             * @param layoutUuid the layout uuid
12318             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12319             * @return the last matching journal article
12320             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12321             * @throws SystemException if a system exception occurred
12322             */
12323            public JournalArticle findByG_L_Last(long groupId, String layoutUuid,
12324                    OrderByComparator orderByComparator)
12325                    throws NoSuchArticleException, SystemException {
12326                    JournalArticle journalArticle = fetchByG_L_Last(groupId, layoutUuid,
12327                                    orderByComparator);
12328    
12329                    if (journalArticle != null) {
12330                            return journalArticle;
12331                    }
12332    
12333                    StringBundler msg = new StringBundler(6);
12334    
12335                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12336    
12337                    msg.append("groupId=");
12338                    msg.append(groupId);
12339    
12340                    msg.append(", layoutUuid=");
12341                    msg.append(layoutUuid);
12342    
12343                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12344    
12345                    throw new NoSuchArticleException(msg.toString());
12346            }
12347    
12348            /**
12349             * Returns the last journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
12350             *
12351             * @param groupId the group ID
12352             * @param layoutUuid the layout uuid
12353             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12354             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
12355             * @throws SystemException if a system exception occurred
12356             */
12357            public JournalArticle fetchByG_L_Last(long groupId, String layoutUuid,
12358                    OrderByComparator orderByComparator) throws SystemException {
12359                    int count = countByG_L(groupId, layoutUuid);
12360    
12361                    List<JournalArticle> list = findByG_L(groupId, layoutUuid, count - 1,
12362                                    count, orderByComparator);
12363    
12364                    if (!list.isEmpty()) {
12365                            return list.get(0);
12366                    }
12367    
12368                    return null;
12369            }
12370    
12371            /**
12372             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
12373             *
12374             * @param id the primary key of the current journal article
12375             * @param groupId the group ID
12376             * @param layoutUuid the layout uuid
12377             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12378             * @return the previous, current, and next journal article
12379             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
12380             * @throws SystemException if a system exception occurred
12381             */
12382            public JournalArticle[] findByG_L_PrevAndNext(long id, long groupId,
12383                    String layoutUuid, OrderByComparator orderByComparator)
12384                    throws NoSuchArticleException, SystemException {
12385                    JournalArticle journalArticle = findByPrimaryKey(id);
12386    
12387                    Session session = null;
12388    
12389                    try {
12390                            session = openSession();
12391    
12392                            JournalArticle[] array = new JournalArticleImpl[3];
12393    
12394                            array[0] = getByG_L_PrevAndNext(session, journalArticle, groupId,
12395                                            layoutUuid, orderByComparator, true);
12396    
12397                            array[1] = journalArticle;
12398    
12399                            array[2] = getByG_L_PrevAndNext(session, journalArticle, groupId,
12400                                            layoutUuid, orderByComparator, false);
12401    
12402                            return array;
12403                    }
12404                    catch (Exception e) {
12405                            throw processException(e);
12406                    }
12407                    finally {
12408                            closeSession(session);
12409                    }
12410            }
12411    
12412            protected JournalArticle getByG_L_PrevAndNext(Session session,
12413                    JournalArticle journalArticle, long groupId, String layoutUuid,
12414                    OrderByComparator orderByComparator, boolean previous) {
12415                    StringBundler query = null;
12416    
12417                    if (orderByComparator != null) {
12418                            query = new StringBundler(6 +
12419                                            (orderByComparator.getOrderByFields().length * 6));
12420                    }
12421                    else {
12422                            query = new StringBundler(3);
12423                    }
12424    
12425                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12426    
12427                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
12428    
12429                    boolean bindLayoutUuid = false;
12430    
12431                    if (layoutUuid == null) {
12432                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
12433                    }
12434                    else if (layoutUuid.equals(StringPool.BLANK)) {
12435                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
12436                    }
12437                    else {
12438                            bindLayoutUuid = true;
12439    
12440                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
12441                    }
12442    
12443                    if (orderByComparator != null) {
12444                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12445    
12446                            if (orderByConditionFields.length > 0) {
12447                                    query.append(WHERE_AND);
12448                            }
12449    
12450                            for (int i = 0; i < orderByConditionFields.length; i++) {
12451                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12452                                    query.append(orderByConditionFields[i]);
12453    
12454                                    if ((i + 1) < orderByConditionFields.length) {
12455                                            if (orderByComparator.isAscending() ^ previous) {
12456                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12457                                            }
12458                                            else {
12459                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12460                                            }
12461                                    }
12462                                    else {
12463                                            if (orderByComparator.isAscending() ^ previous) {
12464                                                    query.append(WHERE_GREATER_THAN);
12465                                            }
12466                                            else {
12467                                                    query.append(WHERE_LESSER_THAN);
12468                                            }
12469                                    }
12470                            }
12471    
12472                            query.append(ORDER_BY_CLAUSE);
12473    
12474                            String[] orderByFields = orderByComparator.getOrderByFields();
12475    
12476                            for (int i = 0; i < orderByFields.length; i++) {
12477                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12478                                    query.append(orderByFields[i]);
12479    
12480                                    if ((i + 1) < orderByFields.length) {
12481                                            if (orderByComparator.isAscending() ^ previous) {
12482                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12483                                            }
12484                                            else {
12485                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12486                                            }
12487                                    }
12488                                    else {
12489                                            if (orderByComparator.isAscending() ^ previous) {
12490                                                    query.append(ORDER_BY_ASC);
12491                                            }
12492                                            else {
12493                                                    query.append(ORDER_BY_DESC);
12494                                            }
12495                                    }
12496                            }
12497                    }
12498                    else {
12499                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12500                    }
12501    
12502                    String sql = query.toString();
12503    
12504                    Query q = session.createQuery(sql);
12505    
12506                    q.setFirstResult(0);
12507                    q.setMaxResults(2);
12508    
12509                    QueryPos qPos = QueryPos.getInstance(q);
12510    
12511                    qPos.add(groupId);
12512    
12513                    if (bindLayoutUuid) {
12514                            qPos.add(layoutUuid);
12515                    }
12516    
12517                    if (orderByComparator != null) {
12518                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12519    
12520                            for (Object value : values) {
12521                                    qPos.add(value);
12522                            }
12523                    }
12524    
12525                    List<JournalArticle> list = q.list();
12526    
12527                    if (list.size() == 2) {
12528                            return list.get(1);
12529                    }
12530                    else {
12531                            return null;
12532                    }
12533            }
12534    
12535            /**
12536             * Returns all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
12537             *
12538             * @param groupId the group ID
12539             * @param layoutUuid the layout uuid
12540             * @return the matching journal articles that the user has permission to view
12541             * @throws SystemException if a system exception occurred
12542             */
12543            public List<JournalArticle> filterFindByG_L(long groupId, String layoutUuid)
12544                    throws SystemException {
12545                    return filterFindByG_L(groupId, layoutUuid, QueryUtil.ALL_POS,
12546                            QueryUtil.ALL_POS, null);
12547            }
12548    
12549            /**
12550             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
12551             *
12552             * <p>
12553             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12554             * </p>
12555             *
12556             * @param groupId the group ID
12557             * @param layoutUuid the layout uuid
12558             * @param start the lower bound of the range of journal articles
12559             * @param end the upper bound of the range of journal articles (not inclusive)
12560             * @return the range of matching journal articles that the user has permission to view
12561             * @throws SystemException if a system exception occurred
12562             */
12563            public List<JournalArticle> filterFindByG_L(long groupId,
12564                    String layoutUuid, int start, int end) throws SystemException {
12565                    return filterFindByG_L(groupId, layoutUuid, start, end, null);
12566            }
12567    
12568            /**
12569             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and layoutUuid = &#63;.
12570             *
12571             * <p>
12572             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12573             * </p>
12574             *
12575             * @param groupId the group ID
12576             * @param layoutUuid the layout uuid
12577             * @param start the lower bound of the range of journal articles
12578             * @param end the upper bound of the range of journal articles (not inclusive)
12579             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12580             * @return the ordered range of matching journal articles that the user has permission to view
12581             * @throws SystemException if a system exception occurred
12582             */
12583            public List<JournalArticle> filterFindByG_L(long groupId,
12584                    String layoutUuid, int start, int end,
12585                    OrderByComparator orderByComparator) throws SystemException {
12586                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12587                            return findByG_L(groupId, layoutUuid, start, end, orderByComparator);
12588                    }
12589    
12590                    StringBundler query = null;
12591    
12592                    if (orderByComparator != null) {
12593                            query = new StringBundler(4 +
12594                                            (orderByComparator.getOrderByFields().length * 3));
12595                    }
12596                    else {
12597                            query = new StringBundler(4);
12598                    }
12599    
12600                    if (getDB().isSupportsInlineDistinct()) {
12601                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
12602                    }
12603                    else {
12604                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
12605                    }
12606    
12607                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
12608    
12609                    boolean bindLayoutUuid = false;
12610    
12611                    if (layoutUuid == null) {
12612                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
12613                    }
12614                    else if (layoutUuid.equals(StringPool.BLANK)) {
12615                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
12616                    }
12617                    else {
12618                            bindLayoutUuid = true;
12619    
12620                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
12621                    }
12622    
12623                    if (!getDB().isSupportsInlineDistinct()) {
12624                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
12625                    }
12626    
12627                    if (orderByComparator != null) {
12628                            if (getDB().isSupportsInlineDistinct()) {
12629                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12630                                            orderByComparator);
12631                            }
12632                            else {
12633                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12634                                            orderByComparator);
12635                            }
12636                    }
12637                    else {
12638                            if (getDB().isSupportsInlineDistinct()) {
12639                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12640                            }
12641                            else {
12642                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12643                            }
12644                    }
12645    
12646                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12647                                    JournalArticle.class.getName(),
12648                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12649    
12650                    Session session = null;
12651    
12652                    try {
12653                            session = openSession();
12654    
12655                            SQLQuery q = session.createSQLQuery(sql);
12656    
12657                            if (getDB().isSupportsInlineDistinct()) {
12658                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12659                            }
12660                            else {
12661                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12662                            }
12663    
12664                            QueryPos qPos = QueryPos.getInstance(q);
12665    
12666                            qPos.add(groupId);
12667    
12668                            if (bindLayoutUuid) {
12669                                    qPos.add(layoutUuid);
12670                            }
12671    
12672                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
12673                                    end);
12674                    }
12675                    catch (Exception e) {
12676                            throw processException(e);
12677                    }
12678                    finally {
12679                            closeSession(session);
12680                    }
12681            }
12682    
12683            /**
12684             * 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;.
12685             *
12686             * @param id the primary key of the current journal article
12687             * @param groupId the group ID
12688             * @param layoutUuid the layout uuid
12689             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12690             * @return the previous, current, and next journal article
12691             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
12692             * @throws SystemException if a system exception occurred
12693             */
12694            public JournalArticle[] filterFindByG_L_PrevAndNext(long id, long groupId,
12695                    String layoutUuid, OrderByComparator orderByComparator)
12696                    throws NoSuchArticleException, SystemException {
12697                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12698                            return findByG_L_PrevAndNext(id, groupId, layoutUuid,
12699                                    orderByComparator);
12700                    }
12701    
12702                    JournalArticle journalArticle = findByPrimaryKey(id);
12703    
12704                    Session session = null;
12705    
12706                    try {
12707                            session = openSession();
12708    
12709                            JournalArticle[] array = new JournalArticleImpl[3];
12710    
12711                            array[0] = filterGetByG_L_PrevAndNext(session, journalArticle,
12712                                            groupId, layoutUuid, orderByComparator, true);
12713    
12714                            array[1] = journalArticle;
12715    
12716                            array[2] = filterGetByG_L_PrevAndNext(session, journalArticle,
12717                                            groupId, layoutUuid, orderByComparator, false);
12718    
12719                            return array;
12720                    }
12721                    catch (Exception e) {
12722                            throw processException(e);
12723                    }
12724                    finally {
12725                            closeSession(session);
12726                    }
12727            }
12728    
12729            protected JournalArticle filterGetByG_L_PrevAndNext(Session session,
12730                    JournalArticle journalArticle, long groupId, String layoutUuid,
12731                    OrderByComparator orderByComparator, boolean previous) {
12732                    StringBundler query = null;
12733    
12734                    if (orderByComparator != null) {
12735                            query = new StringBundler(6 +
12736                                            (orderByComparator.getOrderByFields().length * 6));
12737                    }
12738                    else {
12739                            query = new StringBundler(3);
12740                    }
12741    
12742                    if (getDB().isSupportsInlineDistinct()) {
12743                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
12744                    }
12745                    else {
12746                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
12747                    }
12748    
12749                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
12750    
12751                    boolean bindLayoutUuid = false;
12752    
12753                    if (layoutUuid == null) {
12754                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
12755                    }
12756                    else if (layoutUuid.equals(StringPool.BLANK)) {
12757                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
12758                    }
12759                    else {
12760                            bindLayoutUuid = true;
12761    
12762                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
12763                    }
12764    
12765                    if (!getDB().isSupportsInlineDistinct()) {
12766                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
12767                    }
12768    
12769                    if (orderByComparator != null) {
12770                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12771    
12772                            if (orderByConditionFields.length > 0) {
12773                                    query.append(WHERE_AND);
12774                            }
12775    
12776                            for (int i = 0; i < orderByConditionFields.length; i++) {
12777                                    if (getDB().isSupportsInlineDistinct()) {
12778                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12779                                    }
12780                                    else {
12781                                            query.append(_ORDER_BY_ENTITY_TABLE);
12782                                    }
12783    
12784                                    query.append(orderByConditionFields[i]);
12785    
12786                                    if ((i + 1) < orderByConditionFields.length) {
12787                                            if (orderByComparator.isAscending() ^ previous) {
12788                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12789                                            }
12790                                            else {
12791                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12792                                            }
12793                                    }
12794                                    else {
12795                                            if (orderByComparator.isAscending() ^ previous) {
12796                                                    query.append(WHERE_GREATER_THAN);
12797                                            }
12798                                            else {
12799                                                    query.append(WHERE_LESSER_THAN);
12800                                            }
12801                                    }
12802                            }
12803    
12804                            query.append(ORDER_BY_CLAUSE);
12805    
12806                            String[] orderByFields = orderByComparator.getOrderByFields();
12807    
12808                            for (int i = 0; i < orderByFields.length; i++) {
12809                                    if (getDB().isSupportsInlineDistinct()) {
12810                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12811                                    }
12812                                    else {
12813                                            query.append(_ORDER_BY_ENTITY_TABLE);
12814                                    }
12815    
12816                                    query.append(orderByFields[i]);
12817    
12818                                    if ((i + 1) < orderByFields.length) {
12819                                            if (orderByComparator.isAscending() ^ previous) {
12820                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12821                                            }
12822                                            else {
12823                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12824                                            }
12825                                    }
12826                                    else {
12827                                            if (orderByComparator.isAscending() ^ previous) {
12828                                                    query.append(ORDER_BY_ASC);
12829                                            }
12830                                            else {
12831                                                    query.append(ORDER_BY_DESC);
12832                                            }
12833                                    }
12834                            }
12835                    }
12836                    else {
12837                            if (getDB().isSupportsInlineDistinct()) {
12838                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12839                            }
12840                            else {
12841                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12842                            }
12843                    }
12844    
12845                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12846                                    JournalArticle.class.getName(),
12847                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12848    
12849                    SQLQuery q = session.createSQLQuery(sql);
12850    
12851                    q.setFirstResult(0);
12852                    q.setMaxResults(2);
12853    
12854                    if (getDB().isSupportsInlineDistinct()) {
12855                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12856                    }
12857                    else {
12858                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12859                    }
12860    
12861                    QueryPos qPos = QueryPos.getInstance(q);
12862    
12863                    qPos.add(groupId);
12864    
12865                    if (bindLayoutUuid) {
12866                            qPos.add(layoutUuid);
12867                    }
12868    
12869                    if (orderByComparator != null) {
12870                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12871    
12872                            for (Object value : values) {
12873                                    qPos.add(value);
12874                            }
12875                    }
12876    
12877                    List<JournalArticle> list = q.list();
12878    
12879                    if (list.size() == 2) {
12880                            return list.get(1);
12881                    }
12882                    else {
12883                            return null;
12884                    }
12885            }
12886    
12887            /**
12888             * Removes all the journal articles where groupId = &#63; and layoutUuid = &#63; from the database.
12889             *
12890             * @param groupId the group ID
12891             * @param layoutUuid the layout uuid
12892             * @throws SystemException if a system exception occurred
12893             */
12894            public void removeByG_L(long groupId, String layoutUuid)
12895                    throws SystemException {
12896                    for (JournalArticle journalArticle : findByG_L(groupId, layoutUuid,
12897                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
12898                            remove(journalArticle);
12899                    }
12900            }
12901    
12902            /**
12903             * Returns the number of journal articles where groupId = &#63; and layoutUuid = &#63;.
12904             *
12905             * @param groupId the group ID
12906             * @param layoutUuid the layout uuid
12907             * @return the number of matching journal articles
12908             * @throws SystemException if a system exception occurred
12909             */
12910            public int countByG_L(long groupId, String layoutUuid)
12911                    throws SystemException {
12912                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_L;
12913    
12914                    Object[] finderArgs = new Object[] { groupId, layoutUuid };
12915    
12916                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
12917                                    this);
12918    
12919                    if (count == null) {
12920                            StringBundler query = new StringBundler(3);
12921    
12922                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
12923    
12924                            query.append(_FINDER_COLUMN_G_L_GROUPID_2);
12925    
12926                            boolean bindLayoutUuid = false;
12927    
12928                            if (layoutUuid == null) {
12929                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
12930                            }
12931                            else if (layoutUuid.equals(StringPool.BLANK)) {
12932                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
12933                            }
12934                            else {
12935                                    bindLayoutUuid = true;
12936    
12937                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
12938                            }
12939    
12940                            String sql = query.toString();
12941    
12942                            Session session = null;
12943    
12944                            try {
12945                                    session = openSession();
12946    
12947                                    Query q = session.createQuery(sql);
12948    
12949                                    QueryPos qPos = QueryPos.getInstance(q);
12950    
12951                                    qPos.add(groupId);
12952    
12953                                    if (bindLayoutUuid) {
12954                                            qPos.add(layoutUuid);
12955                                    }
12956    
12957                                    count = (Long)q.uniqueResult();
12958    
12959                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
12960                            }
12961                            catch (Exception e) {
12962                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12963    
12964                                    throw processException(e);
12965                            }
12966                            finally {
12967                                    closeSession(session);
12968                            }
12969                    }
12970    
12971                    return count.intValue();
12972            }
12973    
12974            /**
12975             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
12976             *
12977             * @param groupId the group ID
12978             * @param layoutUuid the layout uuid
12979             * @return the number of matching journal articles that the user has permission to view
12980             * @throws SystemException if a system exception occurred
12981             */
12982            public int filterCountByG_L(long groupId, String layoutUuid)
12983                    throws SystemException {
12984                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12985                            return countByG_L(groupId, layoutUuid);
12986                    }
12987    
12988                    StringBundler query = new StringBundler(3);
12989    
12990                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
12991    
12992                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
12993    
12994                    boolean bindLayoutUuid = false;
12995    
12996                    if (layoutUuid == null) {
12997                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
12998                    }
12999                    else if (layoutUuid.equals(StringPool.BLANK)) {
13000                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
13001                    }
13002                    else {
13003                            bindLayoutUuid = true;
13004    
13005                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
13006                    }
13007    
13008                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13009                                    JournalArticle.class.getName(),
13010                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13011    
13012                    Session session = null;
13013    
13014                    try {
13015                            session = openSession();
13016    
13017                            SQLQuery q = session.createSQLQuery(sql);
13018    
13019                            q.addScalar(COUNT_COLUMN_NAME,
13020                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
13021    
13022                            QueryPos qPos = QueryPos.getInstance(q);
13023    
13024                            qPos.add(groupId);
13025    
13026                            if (bindLayoutUuid) {
13027                                    qPos.add(layoutUuid);
13028                            }
13029    
13030                            Long count = (Long)q.uniqueResult();
13031    
13032                            return count.intValue();
13033                    }
13034                    catch (Exception e) {
13035                            throw processException(e);
13036                    }
13037                    finally {
13038                            closeSession(session);
13039                    }
13040            }
13041    
13042            private static final String _FINDER_COLUMN_G_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
13043            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
13044            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
13045            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = '')";
13046            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13047                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
13048                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
13049                            "findByG_ST",
13050                            new String[] {
13051                                    Long.class.getName(), Integer.class.getName(),
13052                                    
13053                            Integer.class.getName(), Integer.class.getName(),
13054                                    OrderByComparator.class.getName()
13055                            });
13056            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13057                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
13058                            JournalArticleImpl.class,
13059                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_ST",
13060                            new String[] { Long.class.getName(), Integer.class.getName() },
13061                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
13062                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
13063                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
13064                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
13065            public static final FinderPath FINDER_PATH_COUNT_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13066                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
13067                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_ST",
13068                            new String[] { Long.class.getName(), Integer.class.getName() });
13069    
13070            /**
13071             * Returns all the journal articles where groupId = &#63; and status = &#63;.
13072             *
13073             * @param groupId the group ID
13074             * @param status the status
13075             * @return the matching journal articles
13076             * @throws SystemException if a system exception occurred
13077             */
13078            public List<JournalArticle> findByG_ST(long groupId, int status)
13079                    throws SystemException {
13080                    return findByG_ST(groupId, status, QueryUtil.ALL_POS,
13081                            QueryUtil.ALL_POS, null);
13082            }
13083    
13084            /**
13085             * Returns a range of all the journal articles where groupId = &#63; and status = &#63;.
13086             *
13087             * <p>
13088             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13089             * </p>
13090             *
13091             * @param groupId the group ID
13092             * @param status the status
13093             * @param start the lower bound of the range of journal articles
13094             * @param end the upper bound of the range of journal articles (not inclusive)
13095             * @return the range of matching journal articles
13096             * @throws SystemException if a system exception occurred
13097             */
13098            public List<JournalArticle> findByG_ST(long groupId, int status, int start,
13099                    int end) throws SystemException {
13100                    return findByG_ST(groupId, status, start, end, null);
13101            }
13102    
13103            /**
13104             * Returns an ordered range of all the journal articles where groupId = &#63; and status = &#63;.
13105             *
13106             * <p>
13107             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13108             * </p>
13109             *
13110             * @param groupId the group ID
13111             * @param status the status
13112             * @param start the lower bound of the range of journal articles
13113             * @param end the upper bound of the range of journal articles (not inclusive)
13114             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13115             * @return the ordered range of matching journal articles
13116             * @throws SystemException if a system exception occurred
13117             */
13118            public List<JournalArticle> findByG_ST(long groupId, int status, int start,
13119                    int end, OrderByComparator orderByComparator) throws SystemException {
13120                    boolean pagination = true;
13121                    FinderPath finderPath = null;
13122                    Object[] finderArgs = null;
13123    
13124                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13125                                    (orderByComparator == null)) {
13126                            pagination = false;
13127                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST;
13128                            finderArgs = new Object[] { groupId, status };
13129                    }
13130                    else {
13131                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_ST;
13132                            finderArgs = new Object[] {
13133                                            groupId, status,
13134                                            
13135                                            start, end, orderByComparator
13136                                    };
13137                    }
13138    
13139                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
13140                                    finderArgs, this);
13141    
13142                    if ((list != null) && !list.isEmpty()) {
13143                            for (JournalArticle journalArticle : list) {
13144                                    if ((groupId != journalArticle.getGroupId()) ||
13145                                                    (status != journalArticle.getStatus())) {
13146                                            list = null;
13147    
13148                                            break;
13149                                    }
13150                            }
13151                    }
13152    
13153                    if (list == null) {
13154                            StringBundler query = null;
13155    
13156                            if (orderByComparator != null) {
13157                                    query = new StringBundler(4 +
13158                                                    (orderByComparator.getOrderByFields().length * 3));
13159                            }
13160                            else {
13161                                    query = new StringBundler(4);
13162                            }
13163    
13164                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13165    
13166                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
13167    
13168                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
13169    
13170                            if (orderByComparator != null) {
13171                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13172                                            orderByComparator);
13173                            }
13174                            else
13175                             if (pagination) {
13176                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13177                            }
13178    
13179                            String sql = query.toString();
13180    
13181                            Session session = null;
13182    
13183                            try {
13184                                    session = openSession();
13185    
13186                                    Query q = session.createQuery(sql);
13187    
13188                                    QueryPos qPos = QueryPos.getInstance(q);
13189    
13190                                    qPos.add(groupId);
13191    
13192                                    qPos.add(status);
13193    
13194                                    if (!pagination) {
13195                                            list = (List<JournalArticle>)QueryUtil.list(q,
13196                                                            getDialect(), start, end, false);
13197    
13198                                            Collections.sort(list);
13199    
13200                                            list = new UnmodifiableList<JournalArticle>(list);
13201                                    }
13202                                    else {
13203                                            list = (List<JournalArticle>)QueryUtil.list(q,
13204                                                            getDialect(), start, end);
13205                                    }
13206    
13207                                    cacheResult(list);
13208    
13209                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
13210                            }
13211                            catch (Exception e) {
13212                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13213    
13214                                    throw processException(e);
13215                            }
13216                            finally {
13217                                    closeSession(session);
13218                            }
13219                    }
13220    
13221                    return list;
13222            }
13223    
13224            /**
13225             * Returns the first journal article in the ordered set where groupId = &#63; and status = &#63;.
13226             *
13227             * @param groupId the group ID
13228             * @param status the status
13229             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13230             * @return the first matching journal article
13231             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13232             * @throws SystemException if a system exception occurred
13233             */
13234            public JournalArticle findByG_ST_First(long groupId, int status,
13235                    OrderByComparator orderByComparator)
13236                    throws NoSuchArticleException, SystemException {
13237                    JournalArticle journalArticle = fetchByG_ST_First(groupId, status,
13238                                    orderByComparator);
13239    
13240                    if (journalArticle != null) {
13241                            return journalArticle;
13242                    }
13243    
13244                    StringBundler msg = new StringBundler(6);
13245    
13246                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13247    
13248                    msg.append("groupId=");
13249                    msg.append(groupId);
13250    
13251                    msg.append(", status=");
13252                    msg.append(status);
13253    
13254                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13255    
13256                    throw new NoSuchArticleException(msg.toString());
13257            }
13258    
13259            /**
13260             * Returns the first journal article in the ordered set where groupId = &#63; and status = &#63;.
13261             *
13262             * @param groupId the group ID
13263             * @param status the status
13264             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13265             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
13266             * @throws SystemException if a system exception occurred
13267             */
13268            public JournalArticle fetchByG_ST_First(long groupId, int status,
13269                    OrderByComparator orderByComparator) throws SystemException {
13270                    List<JournalArticle> list = findByG_ST(groupId, status, 0, 1,
13271                                    orderByComparator);
13272    
13273                    if (!list.isEmpty()) {
13274                            return list.get(0);
13275                    }
13276    
13277                    return null;
13278            }
13279    
13280            /**
13281             * Returns the last journal article in the ordered set where groupId = &#63; and status = &#63;.
13282             *
13283             * @param groupId the group ID
13284             * @param status the status
13285             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13286             * @return the last matching journal article
13287             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13288             * @throws SystemException if a system exception occurred
13289             */
13290            public JournalArticle findByG_ST_Last(long groupId, int status,
13291                    OrderByComparator orderByComparator)
13292                    throws NoSuchArticleException, SystemException {
13293                    JournalArticle journalArticle = fetchByG_ST_Last(groupId, status,
13294                                    orderByComparator);
13295    
13296                    if (journalArticle != null) {
13297                            return journalArticle;
13298                    }
13299    
13300                    StringBundler msg = new StringBundler(6);
13301    
13302                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13303    
13304                    msg.append("groupId=");
13305                    msg.append(groupId);
13306    
13307                    msg.append(", status=");
13308                    msg.append(status);
13309    
13310                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13311    
13312                    throw new NoSuchArticleException(msg.toString());
13313            }
13314    
13315            /**
13316             * Returns the last journal article in the ordered set where groupId = &#63; and status = &#63;.
13317             *
13318             * @param groupId the group ID
13319             * @param status the status
13320             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13321             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
13322             * @throws SystemException if a system exception occurred
13323             */
13324            public JournalArticle fetchByG_ST_Last(long groupId, int status,
13325                    OrderByComparator orderByComparator) throws SystemException {
13326                    int count = countByG_ST(groupId, status);
13327    
13328                    List<JournalArticle> list = findByG_ST(groupId, status, count - 1,
13329                                    count, orderByComparator);
13330    
13331                    if (!list.isEmpty()) {
13332                            return list.get(0);
13333                    }
13334    
13335                    return null;
13336            }
13337    
13338            /**
13339             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and status = &#63;.
13340             *
13341             * @param id the primary key of the current journal article
13342             * @param groupId the group ID
13343             * @param status the status
13344             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13345             * @return the previous, current, and next journal article
13346             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13347             * @throws SystemException if a system exception occurred
13348             */
13349            public JournalArticle[] findByG_ST_PrevAndNext(long id, long groupId,
13350                    int status, OrderByComparator orderByComparator)
13351                    throws NoSuchArticleException, SystemException {
13352                    JournalArticle journalArticle = findByPrimaryKey(id);
13353    
13354                    Session session = null;
13355    
13356                    try {
13357                            session = openSession();
13358    
13359                            JournalArticle[] array = new JournalArticleImpl[3];
13360    
13361                            array[0] = getByG_ST_PrevAndNext(session, journalArticle, groupId,
13362                                            status, orderByComparator, true);
13363    
13364                            array[1] = journalArticle;
13365    
13366                            array[2] = getByG_ST_PrevAndNext(session, journalArticle, groupId,
13367                                            status, orderByComparator, false);
13368    
13369                            return array;
13370                    }
13371                    catch (Exception e) {
13372                            throw processException(e);
13373                    }
13374                    finally {
13375                            closeSession(session);
13376                    }
13377            }
13378    
13379            protected JournalArticle getByG_ST_PrevAndNext(Session session,
13380                    JournalArticle journalArticle, long groupId, int status,
13381                    OrderByComparator orderByComparator, boolean previous) {
13382                    StringBundler query = null;
13383    
13384                    if (orderByComparator != null) {
13385                            query = new StringBundler(6 +
13386                                            (orderByComparator.getOrderByFields().length * 6));
13387                    }
13388                    else {
13389                            query = new StringBundler(3);
13390                    }
13391    
13392                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13393    
13394                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
13395    
13396                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
13397    
13398                    if (orderByComparator != null) {
13399                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13400    
13401                            if (orderByConditionFields.length > 0) {
13402                                    query.append(WHERE_AND);
13403                            }
13404    
13405                            for (int i = 0; i < orderByConditionFields.length; i++) {
13406                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13407                                    query.append(orderByConditionFields[i]);
13408    
13409                                    if ((i + 1) < orderByConditionFields.length) {
13410                                            if (orderByComparator.isAscending() ^ previous) {
13411                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13412                                            }
13413                                            else {
13414                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13415                                            }
13416                                    }
13417                                    else {
13418                                            if (orderByComparator.isAscending() ^ previous) {
13419                                                    query.append(WHERE_GREATER_THAN);
13420                                            }
13421                                            else {
13422                                                    query.append(WHERE_LESSER_THAN);
13423                                            }
13424                                    }
13425                            }
13426    
13427                            query.append(ORDER_BY_CLAUSE);
13428    
13429                            String[] orderByFields = orderByComparator.getOrderByFields();
13430    
13431                            for (int i = 0; i < orderByFields.length; i++) {
13432                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13433                                    query.append(orderByFields[i]);
13434    
13435                                    if ((i + 1) < orderByFields.length) {
13436                                            if (orderByComparator.isAscending() ^ previous) {
13437                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13438                                            }
13439                                            else {
13440                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13441                                            }
13442                                    }
13443                                    else {
13444                                            if (orderByComparator.isAscending() ^ previous) {
13445                                                    query.append(ORDER_BY_ASC);
13446                                            }
13447                                            else {
13448                                                    query.append(ORDER_BY_DESC);
13449                                            }
13450                                    }
13451                            }
13452                    }
13453                    else {
13454                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13455                    }
13456    
13457                    String sql = query.toString();
13458    
13459                    Query q = session.createQuery(sql);
13460    
13461                    q.setFirstResult(0);
13462                    q.setMaxResults(2);
13463    
13464                    QueryPos qPos = QueryPos.getInstance(q);
13465    
13466                    qPos.add(groupId);
13467    
13468                    qPos.add(status);
13469    
13470                    if (orderByComparator != null) {
13471                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13472    
13473                            for (Object value : values) {
13474                                    qPos.add(value);
13475                            }
13476                    }
13477    
13478                    List<JournalArticle> list = q.list();
13479    
13480                    if (list.size() == 2) {
13481                            return list.get(1);
13482                    }
13483                    else {
13484                            return null;
13485                    }
13486            }
13487    
13488            /**
13489             * Returns all the journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
13490             *
13491             * @param groupId the group ID
13492             * @param status the status
13493             * @return the matching journal articles that the user has permission to view
13494             * @throws SystemException if a system exception occurred
13495             */
13496            public List<JournalArticle> filterFindByG_ST(long groupId, int status)
13497                    throws SystemException {
13498                    return filterFindByG_ST(groupId, status, QueryUtil.ALL_POS,
13499                            QueryUtil.ALL_POS, null);
13500            }
13501    
13502            /**
13503             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
13504             *
13505             * <p>
13506             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13507             * </p>
13508             *
13509             * @param groupId the group ID
13510             * @param status the status
13511             * @param start the lower bound of the range of journal articles
13512             * @param end the upper bound of the range of journal articles (not inclusive)
13513             * @return the range of matching journal articles that the user has permission to view
13514             * @throws SystemException if a system exception occurred
13515             */
13516            public List<JournalArticle> filterFindByG_ST(long groupId, int status,
13517                    int start, int end) throws SystemException {
13518                    return filterFindByG_ST(groupId, status, start, end, null);
13519            }
13520    
13521            /**
13522             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and status = &#63;.
13523             *
13524             * <p>
13525             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13526             * </p>
13527             *
13528             * @param groupId the group ID
13529             * @param status the status
13530             * @param start the lower bound of the range of journal articles
13531             * @param end the upper bound of the range of journal articles (not inclusive)
13532             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13533             * @return the ordered range of matching journal articles that the user has permission to view
13534             * @throws SystemException if a system exception occurred
13535             */
13536            public List<JournalArticle> filterFindByG_ST(long groupId, int status,
13537                    int start, int end, OrderByComparator orderByComparator)
13538                    throws SystemException {
13539                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13540                            return findByG_ST(groupId, status, start, end, orderByComparator);
13541                    }
13542    
13543                    StringBundler query = null;
13544    
13545                    if (orderByComparator != null) {
13546                            query = new StringBundler(4 +
13547                                            (orderByComparator.getOrderByFields().length * 3));
13548                    }
13549                    else {
13550                            query = new StringBundler(4);
13551                    }
13552    
13553                    if (getDB().isSupportsInlineDistinct()) {
13554                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
13555                    }
13556                    else {
13557                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
13558                    }
13559    
13560                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
13561    
13562                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
13563    
13564                    if (!getDB().isSupportsInlineDistinct()) {
13565                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
13566                    }
13567    
13568                    if (orderByComparator != null) {
13569                            if (getDB().isSupportsInlineDistinct()) {
13570                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13571                                            orderByComparator);
13572                            }
13573                            else {
13574                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
13575                                            orderByComparator);
13576                            }
13577                    }
13578                    else {
13579                            if (getDB().isSupportsInlineDistinct()) {
13580                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13581                            }
13582                            else {
13583                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
13584                            }
13585                    }
13586    
13587                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13588                                    JournalArticle.class.getName(),
13589                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13590    
13591                    Session session = null;
13592    
13593                    try {
13594                            session = openSession();
13595    
13596                            SQLQuery q = session.createSQLQuery(sql);
13597    
13598                            if (getDB().isSupportsInlineDistinct()) {
13599                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
13600                            }
13601                            else {
13602                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
13603                            }
13604    
13605                            QueryPos qPos = QueryPos.getInstance(q);
13606    
13607                            qPos.add(groupId);
13608    
13609                            qPos.add(status);
13610    
13611                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
13612                                    end);
13613                    }
13614                    catch (Exception e) {
13615                            throw processException(e);
13616                    }
13617                    finally {
13618                            closeSession(session);
13619                    }
13620            }
13621    
13622            /**
13623             * 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;.
13624             *
13625             * @param id the primary key of the current journal article
13626             * @param groupId the group ID
13627             * @param status the status
13628             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13629             * @return the previous, current, and next journal article
13630             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13631             * @throws SystemException if a system exception occurred
13632             */
13633            public JournalArticle[] filterFindByG_ST_PrevAndNext(long id, long groupId,
13634                    int status, OrderByComparator orderByComparator)
13635                    throws NoSuchArticleException, SystemException {
13636                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13637                            return findByG_ST_PrevAndNext(id, groupId, status, orderByComparator);
13638                    }
13639    
13640                    JournalArticle journalArticle = findByPrimaryKey(id);
13641    
13642                    Session session = null;
13643    
13644                    try {
13645                            session = openSession();
13646    
13647                            JournalArticle[] array = new JournalArticleImpl[3];
13648    
13649                            array[0] = filterGetByG_ST_PrevAndNext(session, journalArticle,
13650                                            groupId, status, orderByComparator, true);
13651    
13652                            array[1] = journalArticle;
13653    
13654                            array[2] = filterGetByG_ST_PrevAndNext(session, journalArticle,
13655                                            groupId, status, orderByComparator, false);
13656    
13657                            return array;
13658                    }
13659                    catch (Exception e) {
13660                            throw processException(e);
13661                    }
13662                    finally {
13663                            closeSession(session);
13664                    }
13665            }
13666    
13667            protected JournalArticle filterGetByG_ST_PrevAndNext(Session session,
13668                    JournalArticle journalArticle, long groupId, int status,
13669                    OrderByComparator orderByComparator, boolean previous) {
13670                    StringBundler query = null;
13671    
13672                    if (orderByComparator != null) {
13673                            query = new StringBundler(6 +
13674                                            (orderByComparator.getOrderByFields().length * 6));
13675                    }
13676                    else {
13677                            query = new StringBundler(3);
13678                    }
13679    
13680                    if (getDB().isSupportsInlineDistinct()) {
13681                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
13682                    }
13683                    else {
13684                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
13685                    }
13686    
13687                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
13688    
13689                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
13690    
13691                    if (!getDB().isSupportsInlineDistinct()) {
13692                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
13693                    }
13694    
13695                    if (orderByComparator != null) {
13696                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13697    
13698                            if (orderByConditionFields.length > 0) {
13699                                    query.append(WHERE_AND);
13700                            }
13701    
13702                            for (int i = 0; i < orderByConditionFields.length; i++) {
13703                                    if (getDB().isSupportsInlineDistinct()) {
13704                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13705                                    }
13706                                    else {
13707                                            query.append(_ORDER_BY_ENTITY_TABLE);
13708                                    }
13709    
13710                                    query.append(orderByConditionFields[i]);
13711    
13712                                    if ((i + 1) < orderByConditionFields.length) {
13713                                            if (orderByComparator.isAscending() ^ previous) {
13714                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13715                                            }
13716                                            else {
13717                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13718                                            }
13719                                    }
13720                                    else {
13721                                            if (orderByComparator.isAscending() ^ previous) {
13722                                                    query.append(WHERE_GREATER_THAN);
13723                                            }
13724                                            else {
13725                                                    query.append(WHERE_LESSER_THAN);
13726                                            }
13727                                    }
13728                            }
13729    
13730                            query.append(ORDER_BY_CLAUSE);
13731    
13732                            String[] orderByFields = orderByComparator.getOrderByFields();
13733    
13734                            for (int i = 0; i < orderByFields.length; i++) {
13735                                    if (getDB().isSupportsInlineDistinct()) {
13736                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13737                                    }
13738                                    else {
13739                                            query.append(_ORDER_BY_ENTITY_TABLE);
13740                                    }
13741    
13742                                    query.append(orderByFields[i]);
13743    
13744                                    if ((i + 1) < orderByFields.length) {
13745                                            if (orderByComparator.isAscending() ^ previous) {
13746                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13747                                            }
13748                                            else {
13749                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13750                                            }
13751                                    }
13752                                    else {
13753                                            if (orderByComparator.isAscending() ^ previous) {
13754                                                    query.append(ORDER_BY_ASC);
13755                                            }
13756                                            else {
13757                                                    query.append(ORDER_BY_DESC);
13758                                            }
13759                                    }
13760                            }
13761                    }
13762                    else {
13763                            if (getDB().isSupportsInlineDistinct()) {
13764                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13765                            }
13766                            else {
13767                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
13768                            }
13769                    }
13770    
13771                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13772                                    JournalArticle.class.getName(),
13773                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13774    
13775                    SQLQuery q = session.createSQLQuery(sql);
13776    
13777                    q.setFirstResult(0);
13778                    q.setMaxResults(2);
13779    
13780                    if (getDB().isSupportsInlineDistinct()) {
13781                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
13782                    }
13783                    else {
13784                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
13785                    }
13786    
13787                    QueryPos qPos = QueryPos.getInstance(q);
13788    
13789                    qPos.add(groupId);
13790    
13791                    qPos.add(status);
13792    
13793                    if (orderByComparator != null) {
13794                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13795    
13796                            for (Object value : values) {
13797                                    qPos.add(value);
13798                            }
13799                    }
13800    
13801                    List<JournalArticle> list = q.list();
13802    
13803                    if (list.size() == 2) {
13804                            return list.get(1);
13805                    }
13806                    else {
13807                            return null;
13808                    }
13809            }
13810    
13811            /**
13812             * Removes all the journal articles where groupId = &#63; and status = &#63; from the database.
13813             *
13814             * @param groupId the group ID
13815             * @param status the status
13816             * @throws SystemException if a system exception occurred
13817             */
13818            public void removeByG_ST(long groupId, int status)
13819                    throws SystemException {
13820                    for (JournalArticle journalArticle : findByG_ST(groupId, status,
13821                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
13822                            remove(journalArticle);
13823                    }
13824            }
13825    
13826            /**
13827             * Returns the number of journal articles where groupId = &#63; and status = &#63;.
13828             *
13829             * @param groupId the group ID
13830             * @param status the status
13831             * @return the number of matching journal articles
13832             * @throws SystemException if a system exception occurred
13833             */
13834            public int countByG_ST(long groupId, int status) throws SystemException {
13835                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_ST;
13836    
13837                    Object[] finderArgs = new Object[] { groupId, status };
13838    
13839                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
13840                                    this);
13841    
13842                    if (count == null) {
13843                            StringBundler query = new StringBundler(3);
13844    
13845                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
13846    
13847                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
13848    
13849                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
13850    
13851                            String sql = query.toString();
13852    
13853                            Session session = null;
13854    
13855                            try {
13856                                    session = openSession();
13857    
13858                                    Query q = session.createQuery(sql);
13859    
13860                                    QueryPos qPos = QueryPos.getInstance(q);
13861    
13862                                    qPos.add(groupId);
13863    
13864                                    qPos.add(status);
13865    
13866                                    count = (Long)q.uniqueResult();
13867    
13868                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
13869                            }
13870                            catch (Exception e) {
13871                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13872    
13873                                    throw processException(e);
13874                            }
13875                            finally {
13876                                    closeSession(session);
13877                            }
13878                    }
13879    
13880                    return count.intValue();
13881            }
13882    
13883            /**
13884             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
13885             *
13886             * @param groupId the group ID
13887             * @param status the status
13888             * @return the number of matching journal articles that the user has permission to view
13889             * @throws SystemException if a system exception occurred
13890             */
13891            public int filterCountByG_ST(long groupId, int status)
13892                    throws SystemException {
13893                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13894                            return countByG_ST(groupId, status);
13895                    }
13896    
13897                    StringBundler query = new StringBundler(3);
13898    
13899                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
13900    
13901                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
13902    
13903                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
13904    
13905                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13906                                    JournalArticle.class.getName(),
13907                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13908    
13909                    Session session = null;
13910    
13911                    try {
13912                            session = openSession();
13913    
13914                            SQLQuery q = session.createSQLQuery(sql);
13915    
13916                            q.addScalar(COUNT_COLUMN_NAME,
13917                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
13918    
13919                            QueryPos qPos = QueryPos.getInstance(q);
13920    
13921                            qPos.add(groupId);
13922    
13923                            qPos.add(status);
13924    
13925                            Long count = (Long)q.uniqueResult();
13926    
13927                            return count.intValue();
13928                    }
13929                    catch (Exception e) {
13930                            throw processException(e);
13931                    }
13932                    finally {
13933                            closeSession(session);
13934                    }
13935            }
13936    
13937            private static final String _FINDER_COLUMN_G_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
13938            private static final String _FINDER_COLUMN_G_ST_STATUS_2 = "journalArticle.status = ?";
13939            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13940                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
13941                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
13942                            "findByC_V",
13943                            new String[] {
13944                                    Long.class.getName(), Double.class.getName(),
13945                                    
13946                            Integer.class.getName(), Integer.class.getName(),
13947                                    OrderByComparator.class.getName()
13948                            });
13949            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13950                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
13951                            JournalArticleImpl.class,
13952                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_V",
13953                            new String[] { Long.class.getName(), Double.class.getName() },
13954                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
13955                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK |
13956                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK);
13957            public static final FinderPath FINDER_PATH_COUNT_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13958                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
13959                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_V",
13960                            new String[] { Long.class.getName(), Double.class.getName() });
13961    
13962            /**
13963             * Returns all the journal articles where companyId = &#63; and version = &#63;.
13964             *
13965             * @param companyId the company ID
13966             * @param version the version
13967             * @return the matching journal articles
13968             * @throws SystemException if a system exception occurred
13969             */
13970            public List<JournalArticle> findByC_V(long companyId, double version)
13971                    throws SystemException {
13972                    return findByC_V(companyId, version, QueryUtil.ALL_POS,
13973                            QueryUtil.ALL_POS, null);
13974            }
13975    
13976            /**
13977             * Returns a range of all the journal articles where companyId = &#63; and version = &#63;.
13978             *
13979             * <p>
13980             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13981             * </p>
13982             *
13983             * @param companyId the company ID
13984             * @param version the version
13985             * @param start the lower bound of the range of journal articles
13986             * @param end the upper bound of the range of journal articles (not inclusive)
13987             * @return the range of matching journal articles
13988             * @throws SystemException if a system exception occurred
13989             */
13990            public List<JournalArticle> findByC_V(long companyId, double version,
13991                    int start, int end) throws SystemException {
13992                    return findByC_V(companyId, version, start, end, null);
13993            }
13994    
13995            /**
13996             * Returns an ordered range of all the journal articles where companyId = &#63; and version = &#63;.
13997             *
13998             * <p>
13999             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14000             * </p>
14001             *
14002             * @param companyId the company ID
14003             * @param version the version
14004             * @param start the lower bound of the range of journal articles
14005             * @param end the upper bound of the range of journal articles (not inclusive)
14006             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14007             * @return the ordered range of matching journal articles
14008             * @throws SystemException if a system exception occurred
14009             */
14010            public List<JournalArticle> findByC_V(long companyId, double version,
14011                    int start, int end, OrderByComparator orderByComparator)
14012                    throws SystemException {
14013                    boolean pagination = true;
14014                    FinderPath finderPath = null;
14015                    Object[] finderArgs = null;
14016    
14017                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
14018                                    (orderByComparator == null)) {
14019                            pagination = false;
14020                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V;
14021                            finderArgs = new Object[] { companyId, version };
14022                    }
14023                    else {
14024                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V;
14025                            finderArgs = new Object[] {
14026                                            companyId, version,
14027                                            
14028                                            start, end, orderByComparator
14029                                    };
14030                    }
14031    
14032                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
14033                                    finderArgs, this);
14034    
14035                    if ((list != null) && !list.isEmpty()) {
14036                            for (JournalArticle journalArticle : list) {
14037                                    if ((companyId != journalArticle.getCompanyId()) ||
14038                                                    (version != journalArticle.getVersion())) {
14039                                            list = null;
14040    
14041                                            break;
14042                                    }
14043                            }
14044                    }
14045    
14046                    if (list == null) {
14047                            StringBundler query = null;
14048    
14049                            if (orderByComparator != null) {
14050                                    query = new StringBundler(4 +
14051                                                    (orderByComparator.getOrderByFields().length * 3));
14052                            }
14053                            else {
14054                                    query = new StringBundler(4);
14055                            }
14056    
14057                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
14058    
14059                            query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
14060    
14061                            query.append(_FINDER_COLUMN_C_V_VERSION_2);
14062    
14063                            if (orderByComparator != null) {
14064                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14065                                            orderByComparator);
14066                            }
14067                            else
14068                             if (pagination) {
14069                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14070                            }
14071    
14072                            String sql = query.toString();
14073    
14074                            Session session = null;
14075    
14076                            try {
14077                                    session = openSession();
14078    
14079                                    Query q = session.createQuery(sql);
14080    
14081                                    QueryPos qPos = QueryPos.getInstance(q);
14082    
14083                                    qPos.add(companyId);
14084    
14085                                    qPos.add(version);
14086    
14087                                    if (!pagination) {
14088                                            list = (List<JournalArticle>)QueryUtil.list(q,
14089                                                            getDialect(), start, end, false);
14090    
14091                                            Collections.sort(list);
14092    
14093                                            list = new UnmodifiableList<JournalArticle>(list);
14094                                    }
14095                                    else {
14096                                            list = (List<JournalArticle>)QueryUtil.list(q,
14097                                                            getDialect(), start, end);
14098                                    }
14099    
14100                                    cacheResult(list);
14101    
14102                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
14103                            }
14104                            catch (Exception e) {
14105                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14106    
14107                                    throw processException(e);
14108                            }
14109                            finally {
14110                                    closeSession(session);
14111                            }
14112                    }
14113    
14114                    return list;
14115            }
14116    
14117            /**
14118             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63;.
14119             *
14120             * @param companyId the company ID
14121             * @param version the version
14122             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14123             * @return the first matching journal article
14124             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
14125             * @throws SystemException if a system exception occurred
14126             */
14127            public JournalArticle findByC_V_First(long companyId, double version,
14128                    OrderByComparator orderByComparator)
14129                    throws NoSuchArticleException, SystemException {
14130                    JournalArticle journalArticle = fetchByC_V_First(companyId, version,
14131                                    orderByComparator);
14132    
14133                    if (journalArticle != null) {
14134                            return journalArticle;
14135                    }
14136    
14137                    StringBundler msg = new StringBundler(6);
14138    
14139                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14140    
14141                    msg.append("companyId=");
14142                    msg.append(companyId);
14143    
14144                    msg.append(", version=");
14145                    msg.append(version);
14146    
14147                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14148    
14149                    throw new NoSuchArticleException(msg.toString());
14150            }
14151    
14152            /**
14153             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63;.
14154             *
14155             * @param companyId the company ID
14156             * @param version the version
14157             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14158             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
14159             * @throws SystemException if a system exception occurred
14160             */
14161            public JournalArticle fetchByC_V_First(long companyId, double version,
14162                    OrderByComparator orderByComparator) throws SystemException {
14163                    List<JournalArticle> list = findByC_V(companyId, version, 0, 1,
14164                                    orderByComparator);
14165    
14166                    if (!list.isEmpty()) {
14167                            return list.get(0);
14168                    }
14169    
14170                    return null;
14171            }
14172    
14173            /**
14174             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63;.
14175             *
14176             * @param companyId the company ID
14177             * @param version the version
14178             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14179             * @return the last matching journal article
14180             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
14181             * @throws SystemException if a system exception occurred
14182             */
14183            public JournalArticle findByC_V_Last(long companyId, double version,
14184                    OrderByComparator orderByComparator)
14185                    throws NoSuchArticleException, SystemException {
14186                    JournalArticle journalArticle = fetchByC_V_Last(companyId, version,
14187                                    orderByComparator);
14188    
14189                    if (journalArticle != null) {
14190                            return journalArticle;
14191                    }
14192    
14193                    StringBundler msg = new StringBundler(6);
14194    
14195                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14196    
14197                    msg.append("companyId=");
14198                    msg.append(companyId);
14199    
14200                    msg.append(", version=");
14201                    msg.append(version);
14202    
14203                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14204    
14205                    throw new NoSuchArticleException(msg.toString());
14206            }
14207    
14208            /**
14209             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63;.
14210             *
14211             * @param companyId the company ID
14212             * @param version the version
14213             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14214             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
14215             * @throws SystemException if a system exception occurred
14216             */
14217            public JournalArticle fetchByC_V_Last(long companyId, double version,
14218                    OrderByComparator orderByComparator) throws SystemException {
14219                    int count = countByC_V(companyId, version);
14220    
14221                    List<JournalArticle> list = findByC_V(companyId, version, count - 1,
14222                                    count, orderByComparator);
14223    
14224                    if (!list.isEmpty()) {
14225                            return list.get(0);
14226                    }
14227    
14228                    return null;
14229            }
14230    
14231            /**
14232             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and version = &#63;.
14233             *
14234             * @param id the primary key of the current journal article
14235             * @param companyId the company ID
14236             * @param version the version
14237             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14238             * @return the previous, current, and next journal article
14239             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
14240             * @throws SystemException if a system exception occurred
14241             */
14242            public JournalArticle[] findByC_V_PrevAndNext(long id, long companyId,
14243                    double version, OrderByComparator orderByComparator)
14244                    throws NoSuchArticleException, SystemException {
14245                    JournalArticle journalArticle = findByPrimaryKey(id);
14246    
14247                    Session session = null;
14248    
14249                    try {
14250                            session = openSession();
14251    
14252                            JournalArticle[] array = new JournalArticleImpl[3];
14253    
14254                            array[0] = getByC_V_PrevAndNext(session, journalArticle, companyId,
14255                                            version, orderByComparator, true);
14256    
14257                            array[1] = journalArticle;
14258    
14259                            array[2] = getByC_V_PrevAndNext(session, journalArticle, companyId,
14260                                            version, orderByComparator, false);
14261    
14262                            return array;
14263                    }
14264                    catch (Exception e) {
14265                            throw processException(e);
14266                    }
14267                    finally {
14268                            closeSession(session);
14269                    }
14270            }
14271    
14272            protected JournalArticle getByC_V_PrevAndNext(Session session,
14273                    JournalArticle journalArticle, long companyId, double version,
14274                    OrderByComparator orderByComparator, boolean previous) {
14275                    StringBundler query = null;
14276    
14277                    if (orderByComparator != null) {
14278                            query = new StringBundler(6 +
14279                                            (orderByComparator.getOrderByFields().length * 6));
14280                    }
14281                    else {
14282                            query = new StringBundler(3);
14283                    }
14284    
14285                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
14286    
14287                    query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
14288    
14289                    query.append(_FINDER_COLUMN_C_V_VERSION_2);
14290    
14291                    if (orderByComparator != null) {
14292                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14293    
14294                            if (orderByConditionFields.length > 0) {
14295                                    query.append(WHERE_AND);
14296                            }
14297    
14298                            for (int i = 0; i < orderByConditionFields.length; i++) {
14299                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14300                                    query.append(orderByConditionFields[i]);
14301    
14302                                    if ((i + 1) < orderByConditionFields.length) {
14303                                            if (orderByComparator.isAscending() ^ previous) {
14304                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14305                                            }
14306                                            else {
14307                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14308                                            }
14309                                    }
14310                                    else {
14311                                            if (orderByComparator.isAscending() ^ previous) {
14312                                                    query.append(WHERE_GREATER_THAN);
14313                                            }
14314                                            else {
14315                                                    query.append(WHERE_LESSER_THAN);
14316                                            }
14317                                    }
14318                            }
14319    
14320                            query.append(ORDER_BY_CLAUSE);
14321    
14322                            String[] orderByFields = orderByComparator.getOrderByFields();
14323    
14324                            for (int i = 0; i < orderByFields.length; i++) {
14325                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14326                                    query.append(orderByFields[i]);
14327    
14328                                    if ((i + 1) < orderByFields.length) {
14329                                            if (orderByComparator.isAscending() ^ previous) {
14330                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14331                                            }
14332                                            else {
14333                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14334                                            }
14335                                    }
14336                                    else {
14337                                            if (orderByComparator.isAscending() ^ previous) {
14338                                                    query.append(ORDER_BY_ASC);
14339                                            }
14340                                            else {
14341                                                    query.append(ORDER_BY_DESC);
14342                                            }
14343                                    }
14344                            }
14345                    }
14346                    else {
14347                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14348                    }
14349    
14350                    String sql = query.toString();
14351    
14352                    Query q = session.createQuery(sql);
14353    
14354                    q.setFirstResult(0);
14355                    q.setMaxResults(2);
14356    
14357                    QueryPos qPos = QueryPos.getInstance(q);
14358    
14359                    qPos.add(companyId);
14360    
14361                    qPos.add(version);
14362    
14363                    if (orderByComparator != null) {
14364                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
14365    
14366                            for (Object value : values) {
14367                                    qPos.add(value);
14368                            }
14369                    }
14370    
14371                    List<JournalArticle> list = q.list();
14372    
14373                    if (list.size() == 2) {
14374                            return list.get(1);
14375                    }
14376                    else {
14377                            return null;
14378                    }
14379            }
14380    
14381            /**
14382             * Removes all the journal articles where companyId = &#63; and version = &#63; from the database.
14383             *
14384             * @param companyId the company ID
14385             * @param version the version
14386             * @throws SystemException if a system exception occurred
14387             */
14388            public void removeByC_V(long companyId, double version)
14389                    throws SystemException {
14390                    for (JournalArticle journalArticle : findByC_V(companyId, version,
14391                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14392                            remove(journalArticle);
14393                    }
14394            }
14395    
14396            /**
14397             * Returns the number of journal articles where companyId = &#63; and version = &#63;.
14398             *
14399             * @param companyId the company ID
14400             * @param version the version
14401             * @return the number of matching journal articles
14402             * @throws SystemException if a system exception occurred
14403             */
14404            public int countByC_V(long companyId, double version)
14405                    throws SystemException {
14406                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_V;
14407    
14408                    Object[] finderArgs = new Object[] { companyId, version };
14409    
14410                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
14411                                    this);
14412    
14413                    if (count == null) {
14414                            StringBundler query = new StringBundler(3);
14415    
14416                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14417    
14418                            query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
14419    
14420                            query.append(_FINDER_COLUMN_C_V_VERSION_2);
14421    
14422                            String sql = query.toString();
14423    
14424                            Session session = null;
14425    
14426                            try {
14427                                    session = openSession();
14428    
14429                                    Query q = session.createQuery(sql);
14430    
14431                                    QueryPos qPos = QueryPos.getInstance(q);
14432    
14433                                    qPos.add(companyId);
14434    
14435                                    qPos.add(version);
14436    
14437                                    count = (Long)q.uniqueResult();
14438    
14439                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
14440                            }
14441                            catch (Exception e) {
14442                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14443    
14444                                    throw processException(e);
14445                            }
14446                            finally {
14447                                    closeSession(session);
14448                            }
14449                    }
14450    
14451                    return count.intValue();
14452            }
14453    
14454            private static final String _FINDER_COLUMN_C_V_COMPANYID_2 = "journalArticle.companyId = ? AND ";
14455            private static final String _FINDER_COLUMN_C_V_VERSION_2 = "journalArticle.version = ?";
14456            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14457                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
14458                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
14459                            "findByC_ST",
14460                            new String[] {
14461                                    Long.class.getName(), Integer.class.getName(),
14462                                    
14463                            Integer.class.getName(), Integer.class.getName(),
14464                                    OrderByComparator.class.getName()
14465                            });
14466            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14467                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
14468                            JournalArticleImpl.class,
14469                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_ST",
14470                            new String[] { Long.class.getName(), Integer.class.getName() },
14471                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
14472                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
14473                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
14474                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
14475            public static final FinderPath FINDER_PATH_COUNT_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14476                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
14477                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_ST",
14478                            new String[] { Long.class.getName(), Integer.class.getName() });
14479    
14480            /**
14481             * Returns all the journal articles where companyId = &#63; and status = &#63;.
14482             *
14483             * @param companyId the company ID
14484             * @param status the status
14485             * @return the matching journal articles
14486             * @throws SystemException if a system exception occurred
14487             */
14488            public List<JournalArticle> findByC_ST(long companyId, int status)
14489                    throws SystemException {
14490                    return findByC_ST(companyId, status, QueryUtil.ALL_POS,
14491                            QueryUtil.ALL_POS, null);
14492            }
14493    
14494            /**
14495             * Returns a range of all the journal articles where companyId = &#63; and status = &#63;.
14496             *
14497             * <p>
14498             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14499             * </p>
14500             *
14501             * @param companyId the company ID
14502             * @param status the status
14503             * @param start the lower bound of the range of journal articles
14504             * @param end the upper bound of the range of journal articles (not inclusive)
14505             * @return the range of matching journal articles
14506             * @throws SystemException if a system exception occurred
14507             */
14508            public List<JournalArticle> findByC_ST(long companyId, int status,
14509                    int start, int end) throws SystemException {
14510                    return findByC_ST(companyId, status, start, end, null);
14511            }
14512    
14513            /**
14514             * Returns an ordered range of all the journal articles where companyId = &#63; and status = &#63;.
14515             *
14516             * <p>
14517             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14518             * </p>
14519             *
14520             * @param companyId the company ID
14521             * @param status the status
14522             * @param start the lower bound of the range of journal articles
14523             * @param end the upper bound of the range of journal articles (not inclusive)
14524             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14525             * @return the ordered range of matching journal articles
14526             * @throws SystemException if a system exception occurred
14527             */
14528            public List<JournalArticle> findByC_ST(long companyId, int status,
14529                    int start, int end, OrderByComparator orderByComparator)
14530                    throws SystemException {
14531                    boolean pagination = true;
14532                    FinderPath finderPath = null;
14533                    Object[] finderArgs = null;
14534    
14535                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
14536                                    (orderByComparator == null)) {
14537                            pagination = false;
14538                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST;
14539                            finderArgs = new Object[] { companyId, status };
14540                    }
14541                    else {
14542                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_ST;
14543                            finderArgs = new Object[] {
14544                                            companyId, status,
14545                                            
14546                                            start, end, orderByComparator
14547                                    };
14548                    }
14549    
14550                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
14551                                    finderArgs, this);
14552    
14553                    if ((list != null) && !list.isEmpty()) {
14554                            for (JournalArticle journalArticle : list) {
14555                                    if ((companyId != journalArticle.getCompanyId()) ||
14556                                                    (status != journalArticle.getStatus())) {
14557                                            list = null;
14558    
14559                                            break;
14560                                    }
14561                            }
14562                    }
14563    
14564                    if (list == null) {
14565                            StringBundler query = null;
14566    
14567                            if (orderByComparator != null) {
14568                                    query = new StringBundler(4 +
14569                                                    (orderByComparator.getOrderByFields().length * 3));
14570                            }
14571                            else {
14572                                    query = new StringBundler(4);
14573                            }
14574    
14575                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
14576    
14577                            query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
14578    
14579                            query.append(_FINDER_COLUMN_C_ST_STATUS_2);
14580    
14581                            if (orderByComparator != null) {
14582                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14583                                            orderByComparator);
14584                            }
14585                            else
14586                             if (pagination) {
14587                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14588                            }
14589    
14590                            String sql = query.toString();
14591    
14592                            Session session = null;
14593    
14594                            try {
14595                                    session = openSession();
14596    
14597                                    Query q = session.createQuery(sql);
14598    
14599                                    QueryPos qPos = QueryPos.getInstance(q);
14600    
14601                                    qPos.add(companyId);
14602    
14603                                    qPos.add(status);
14604    
14605                                    if (!pagination) {
14606                                            list = (List<JournalArticle>)QueryUtil.list(q,
14607                                                            getDialect(), start, end, false);
14608    
14609                                            Collections.sort(list);
14610    
14611                                            list = new UnmodifiableList<JournalArticle>(list);
14612                                    }
14613                                    else {
14614                                            list = (List<JournalArticle>)QueryUtil.list(q,
14615                                                            getDialect(), start, end);
14616                                    }
14617    
14618                                    cacheResult(list);
14619    
14620                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
14621                            }
14622                            catch (Exception e) {
14623                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14624    
14625                                    throw processException(e);
14626                            }
14627                            finally {
14628                                    closeSession(session);
14629                            }
14630                    }
14631    
14632                    return list;
14633            }
14634    
14635            /**
14636             * Returns the first journal article in the ordered set where companyId = &#63; and status = &#63;.
14637             *
14638             * @param companyId the company ID
14639             * @param status the status
14640             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14641             * @return the first matching journal article
14642             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
14643             * @throws SystemException if a system exception occurred
14644             */
14645            public JournalArticle findByC_ST_First(long companyId, int status,
14646                    OrderByComparator orderByComparator)
14647                    throws NoSuchArticleException, SystemException {
14648                    JournalArticle journalArticle = fetchByC_ST_First(companyId, status,
14649                                    orderByComparator);
14650    
14651                    if (journalArticle != null) {
14652                            return journalArticle;
14653                    }
14654    
14655                    StringBundler msg = new StringBundler(6);
14656    
14657                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14658    
14659                    msg.append("companyId=");
14660                    msg.append(companyId);
14661    
14662                    msg.append(", status=");
14663                    msg.append(status);
14664    
14665                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14666    
14667                    throw new NoSuchArticleException(msg.toString());
14668            }
14669    
14670            /**
14671             * Returns the first journal article in the ordered set where companyId = &#63; and status = &#63;.
14672             *
14673             * @param companyId the company ID
14674             * @param status the status
14675             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14676             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
14677             * @throws SystemException if a system exception occurred
14678             */
14679            public JournalArticle fetchByC_ST_First(long companyId, int status,
14680                    OrderByComparator orderByComparator) throws SystemException {
14681                    List<JournalArticle> list = findByC_ST(companyId, status, 0, 1,
14682                                    orderByComparator);
14683    
14684                    if (!list.isEmpty()) {
14685                            return list.get(0);
14686                    }
14687    
14688                    return null;
14689            }
14690    
14691            /**
14692             * Returns the last journal article in the ordered set where companyId = &#63; and status = &#63;.
14693             *
14694             * @param companyId the company ID
14695             * @param status the status
14696             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14697             * @return the last matching journal article
14698             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
14699             * @throws SystemException if a system exception occurred
14700             */
14701            public JournalArticle findByC_ST_Last(long companyId, int status,
14702                    OrderByComparator orderByComparator)
14703                    throws NoSuchArticleException, SystemException {
14704                    JournalArticle journalArticle = fetchByC_ST_Last(companyId, status,
14705                                    orderByComparator);
14706    
14707                    if (journalArticle != null) {
14708                            return journalArticle;
14709                    }
14710    
14711                    StringBundler msg = new StringBundler(6);
14712    
14713                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14714    
14715                    msg.append("companyId=");
14716                    msg.append(companyId);
14717    
14718                    msg.append(", status=");
14719                    msg.append(status);
14720    
14721                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14722    
14723                    throw new NoSuchArticleException(msg.toString());
14724            }
14725    
14726            /**
14727             * Returns the last journal article in the ordered set where companyId = &#63; and status = &#63;.
14728             *
14729             * @param companyId the company ID
14730             * @param status the status
14731             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14732             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
14733             * @throws SystemException if a system exception occurred
14734             */
14735            public JournalArticle fetchByC_ST_Last(long companyId, int status,
14736                    OrderByComparator orderByComparator) throws SystemException {
14737                    int count = countByC_ST(companyId, status);
14738    
14739                    List<JournalArticle> list = findByC_ST(companyId, status, count - 1,
14740                                    count, orderByComparator);
14741    
14742                    if (!list.isEmpty()) {
14743                            return list.get(0);
14744                    }
14745    
14746                    return null;
14747            }
14748    
14749            /**
14750             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and status = &#63;.
14751             *
14752             * @param id the primary key of the current journal article
14753             * @param companyId the company ID
14754             * @param status the status
14755             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14756             * @return the previous, current, and next journal article
14757             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
14758             * @throws SystemException if a system exception occurred
14759             */
14760            public JournalArticle[] findByC_ST_PrevAndNext(long id, long companyId,
14761                    int status, OrderByComparator orderByComparator)
14762                    throws NoSuchArticleException, SystemException {
14763                    JournalArticle journalArticle = findByPrimaryKey(id);
14764    
14765                    Session session = null;
14766    
14767                    try {
14768                            session = openSession();
14769    
14770                            JournalArticle[] array = new JournalArticleImpl[3];
14771    
14772                            array[0] = getByC_ST_PrevAndNext(session, journalArticle,
14773                                            companyId, status, orderByComparator, true);
14774    
14775                            array[1] = journalArticle;
14776    
14777                            array[2] = getByC_ST_PrevAndNext(session, journalArticle,
14778                                            companyId, status, orderByComparator, false);
14779    
14780                            return array;
14781                    }
14782                    catch (Exception e) {
14783                            throw processException(e);
14784                    }
14785                    finally {
14786                            closeSession(session);
14787                    }
14788            }
14789    
14790            protected JournalArticle getByC_ST_PrevAndNext(Session session,
14791                    JournalArticle journalArticle, long companyId, int status,
14792                    OrderByComparator orderByComparator, boolean previous) {
14793                    StringBundler query = null;
14794    
14795                    if (orderByComparator != null) {
14796                            query = new StringBundler(6 +
14797                                            (orderByComparator.getOrderByFields().length * 6));
14798                    }
14799                    else {
14800                            query = new StringBundler(3);
14801                    }
14802    
14803                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
14804    
14805                    query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
14806    
14807                    query.append(_FINDER_COLUMN_C_ST_STATUS_2);
14808    
14809                    if (orderByComparator != null) {
14810                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14811    
14812                            if (orderByConditionFields.length > 0) {
14813                                    query.append(WHERE_AND);
14814                            }
14815    
14816                            for (int i = 0; i < orderByConditionFields.length; i++) {
14817                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14818                                    query.append(orderByConditionFields[i]);
14819    
14820                                    if ((i + 1) < orderByConditionFields.length) {
14821                                            if (orderByComparator.isAscending() ^ previous) {
14822                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14823                                            }
14824                                            else {
14825                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14826                                            }
14827                                    }
14828                                    else {
14829                                            if (orderByComparator.isAscending() ^ previous) {
14830                                                    query.append(WHERE_GREATER_THAN);
14831                                            }
14832                                            else {
14833                                                    query.append(WHERE_LESSER_THAN);
14834                                            }
14835                                    }
14836                            }
14837    
14838                            query.append(ORDER_BY_CLAUSE);
14839    
14840                            String[] orderByFields = orderByComparator.getOrderByFields();
14841    
14842                            for (int i = 0; i < orderByFields.length; i++) {
14843                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14844                                    query.append(orderByFields[i]);
14845    
14846                                    if ((i + 1) < orderByFields.length) {
14847                                            if (orderByComparator.isAscending() ^ previous) {
14848                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14849                                            }
14850                                            else {
14851                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14852                                            }
14853                                    }
14854                                    else {
14855                                            if (orderByComparator.isAscending() ^ previous) {
14856                                                    query.append(ORDER_BY_ASC);
14857                                            }
14858                                            else {
14859                                                    query.append(ORDER_BY_DESC);
14860                                            }
14861                                    }
14862                            }
14863                    }
14864                    else {
14865                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14866                    }
14867    
14868                    String sql = query.toString();
14869    
14870                    Query q = session.createQuery(sql);
14871    
14872                    q.setFirstResult(0);
14873                    q.setMaxResults(2);
14874    
14875                    QueryPos qPos = QueryPos.getInstance(q);
14876    
14877                    qPos.add(companyId);
14878    
14879                    qPos.add(status);
14880    
14881                    if (orderByComparator != null) {
14882                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
14883    
14884                            for (Object value : values) {
14885                                    qPos.add(value);
14886                            }
14887                    }
14888    
14889                    List<JournalArticle> list = q.list();
14890    
14891                    if (list.size() == 2) {
14892                            return list.get(1);
14893                    }
14894                    else {
14895                            return null;
14896                    }
14897            }
14898    
14899            /**
14900             * Removes all the journal articles where companyId = &#63; and status = &#63; from the database.
14901             *
14902             * @param companyId the company ID
14903             * @param status the status
14904             * @throws SystemException if a system exception occurred
14905             */
14906            public void removeByC_ST(long companyId, int status)
14907                    throws SystemException {
14908                    for (JournalArticle journalArticle : findByC_ST(companyId, status,
14909                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14910                            remove(journalArticle);
14911                    }
14912            }
14913    
14914            /**
14915             * Returns the number of journal articles where companyId = &#63; and status = &#63;.
14916             *
14917             * @param companyId the company ID
14918             * @param status the status
14919             * @return the number of matching journal articles
14920             * @throws SystemException if a system exception occurred
14921             */
14922            public int countByC_ST(long companyId, int status)
14923                    throws SystemException {
14924                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_ST;
14925    
14926                    Object[] finderArgs = new Object[] { companyId, status };
14927    
14928                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
14929                                    this);
14930    
14931                    if (count == null) {
14932                            StringBundler query = new StringBundler(3);
14933    
14934                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14935    
14936                            query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
14937    
14938                            query.append(_FINDER_COLUMN_C_ST_STATUS_2);
14939    
14940                            String sql = query.toString();
14941    
14942                            Session session = null;
14943    
14944                            try {
14945                                    session = openSession();
14946    
14947                                    Query q = session.createQuery(sql);
14948    
14949                                    QueryPos qPos = QueryPos.getInstance(q);
14950    
14951                                    qPos.add(companyId);
14952    
14953                                    qPos.add(status);
14954    
14955                                    count = (Long)q.uniqueResult();
14956    
14957                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
14958                            }
14959                            catch (Exception e) {
14960                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14961    
14962                                    throw processException(e);
14963                            }
14964                            finally {
14965                                    closeSession(session);
14966                            }
14967                    }
14968    
14969                    return count.intValue();
14970            }
14971    
14972            private static final String _FINDER_COLUMN_C_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
14973            private static final String _FINDER_COLUMN_C_ST_STATUS_2 = "journalArticle.status = ?";
14974            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14975                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
14976                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
14977                            "findByG_F_ST",
14978                            new String[] {
14979                                    Long.class.getName(), Long.class.getName(),
14980                                    Integer.class.getName(),
14981                                    
14982                            Integer.class.getName(), Integer.class.getName(),
14983                                    OrderByComparator.class.getName()
14984                            });
14985            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST =
14986                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14987                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
14988                            JournalArticleImpl.class,
14989                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F_ST",
14990                            new String[] {
14991                                    Long.class.getName(), Long.class.getName(),
14992                                    Integer.class.getName()
14993                            },
14994                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
14995                            JournalArticleModelImpl.FOLDERID_COLUMN_BITMASK |
14996                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
14997                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
14998                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
14999            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15000                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
15001                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_ST",
15002                            new String[] {
15003                                    Long.class.getName(), Long.class.getName(),
15004                                    Integer.class.getName()
15005                            });
15006            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15007                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
15008                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F_ST",
15009                            new String[] {
15010                                    Long.class.getName(), Long.class.getName(),
15011                                    Integer.class.getName()
15012                            });
15013    
15014            /**
15015             * Returns all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
15016             *
15017             * @param groupId the group ID
15018             * @param folderId the folder ID
15019             * @param status the status
15020             * @return the matching journal articles
15021             * @throws SystemException if a system exception occurred
15022             */
15023            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
15024                    int status) throws SystemException {
15025                    return findByG_F_ST(groupId, folderId, status, QueryUtil.ALL_POS,
15026                            QueryUtil.ALL_POS, null);
15027            }
15028    
15029            /**
15030             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
15031             *
15032             * <p>
15033             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15034             * </p>
15035             *
15036             * @param groupId the group ID
15037             * @param folderId the folder ID
15038             * @param status the status
15039             * @param start the lower bound of the range of journal articles
15040             * @param end the upper bound of the range of journal articles (not inclusive)
15041             * @return the range of matching journal articles
15042             * @throws SystemException if a system exception occurred
15043             */
15044            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
15045                    int status, int start, int end) throws SystemException {
15046                    return findByG_F_ST(groupId, folderId, status, start, end, null);
15047            }
15048    
15049            /**
15050             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
15051             *
15052             * <p>
15053             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15054             * </p>
15055             *
15056             * @param groupId the group ID
15057             * @param folderId the folder ID
15058             * @param status the status
15059             * @param start the lower bound of the range of journal articles
15060             * @param end the upper bound of the range of journal articles (not inclusive)
15061             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15062             * @return the ordered range of matching journal articles
15063             * @throws SystemException if a system exception occurred
15064             */
15065            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
15066                    int status, int start, int end, OrderByComparator orderByComparator)
15067                    throws SystemException {
15068                    boolean pagination = true;
15069                    FinderPath finderPath = null;
15070                    Object[] finderArgs = null;
15071    
15072                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
15073                                    (orderByComparator == null)) {
15074                            pagination = false;
15075                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST;
15076                            finderArgs = new Object[] { groupId, folderId, status };
15077                    }
15078                    else {
15079                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST;
15080                            finderArgs = new Object[] {
15081                                            groupId, folderId, status,
15082                                            
15083                                            start, end, orderByComparator
15084                                    };
15085                    }
15086    
15087                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
15088                                    finderArgs, this);
15089    
15090                    if ((list != null) && !list.isEmpty()) {
15091                            for (JournalArticle journalArticle : list) {
15092                                    if ((groupId != journalArticle.getGroupId()) ||
15093                                                    (folderId != journalArticle.getFolderId()) ||
15094                                                    (status != journalArticle.getStatus())) {
15095                                            list = null;
15096    
15097                                            break;
15098                                    }
15099                            }
15100                    }
15101    
15102                    if (list == null) {
15103                            StringBundler query = null;
15104    
15105                            if (orderByComparator != null) {
15106                                    query = new StringBundler(5 +
15107                                                    (orderByComparator.getOrderByFields().length * 3));
15108                            }
15109                            else {
15110                                    query = new StringBundler(5);
15111                            }
15112    
15113                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15114    
15115                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
15116    
15117                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
15118    
15119                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
15120    
15121                            if (orderByComparator != null) {
15122                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15123                                            orderByComparator);
15124                            }
15125                            else
15126                             if (pagination) {
15127                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15128                            }
15129    
15130                            String sql = query.toString();
15131    
15132                            Session session = null;
15133    
15134                            try {
15135                                    session = openSession();
15136    
15137                                    Query q = session.createQuery(sql);
15138    
15139                                    QueryPos qPos = QueryPos.getInstance(q);
15140    
15141                                    qPos.add(groupId);
15142    
15143                                    qPos.add(folderId);
15144    
15145                                    qPos.add(status);
15146    
15147                                    if (!pagination) {
15148                                            list = (List<JournalArticle>)QueryUtil.list(q,
15149                                                            getDialect(), start, end, false);
15150    
15151                                            Collections.sort(list);
15152    
15153                                            list = new UnmodifiableList<JournalArticle>(list);
15154                                    }
15155                                    else {
15156                                            list = (List<JournalArticle>)QueryUtil.list(q,
15157                                                            getDialect(), start, end);
15158                                    }
15159    
15160                                    cacheResult(list);
15161    
15162                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
15163                            }
15164                            catch (Exception e) {
15165                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15166    
15167                                    throw processException(e);
15168                            }
15169                            finally {
15170                                    closeSession(session);
15171                            }
15172                    }
15173    
15174                    return list;
15175            }
15176    
15177            /**
15178             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
15179             *
15180             * @param groupId the group ID
15181             * @param folderId the folder ID
15182             * @param status the status
15183             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15184             * @return the first matching journal article
15185             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15186             * @throws SystemException if a system exception occurred
15187             */
15188            public JournalArticle findByG_F_ST_First(long groupId, long folderId,
15189                    int status, OrderByComparator orderByComparator)
15190                    throws NoSuchArticleException, SystemException {
15191                    JournalArticle journalArticle = fetchByG_F_ST_First(groupId, folderId,
15192                                    status, orderByComparator);
15193    
15194                    if (journalArticle != null) {
15195                            return journalArticle;
15196                    }
15197    
15198                    StringBundler msg = new StringBundler(8);
15199    
15200                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15201    
15202                    msg.append("groupId=");
15203                    msg.append(groupId);
15204    
15205                    msg.append(", folderId=");
15206                    msg.append(folderId);
15207    
15208                    msg.append(", status=");
15209                    msg.append(status);
15210    
15211                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15212    
15213                    throw new NoSuchArticleException(msg.toString());
15214            }
15215    
15216            /**
15217             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
15218             *
15219             * @param groupId the group ID
15220             * @param folderId the folder ID
15221             * @param status the status
15222             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15223             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
15224             * @throws SystemException if a system exception occurred
15225             */
15226            public JournalArticle fetchByG_F_ST_First(long groupId, long folderId,
15227                    int status, OrderByComparator orderByComparator)
15228                    throws SystemException {
15229                    List<JournalArticle> list = findByG_F_ST(groupId, folderId, status, 0,
15230                                    1, orderByComparator);
15231    
15232                    if (!list.isEmpty()) {
15233                            return list.get(0);
15234                    }
15235    
15236                    return null;
15237            }
15238    
15239            /**
15240             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
15241             *
15242             * @param groupId the group ID
15243             * @param folderId the folder ID
15244             * @param status the status
15245             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15246             * @return the last matching journal article
15247             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15248             * @throws SystemException if a system exception occurred
15249             */
15250            public JournalArticle findByG_F_ST_Last(long groupId, long folderId,
15251                    int status, OrderByComparator orderByComparator)
15252                    throws NoSuchArticleException, SystemException {
15253                    JournalArticle journalArticle = fetchByG_F_ST_Last(groupId, folderId,
15254                                    status, orderByComparator);
15255    
15256                    if (journalArticle != null) {
15257                            return journalArticle;
15258                    }
15259    
15260                    StringBundler msg = new StringBundler(8);
15261    
15262                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15263    
15264                    msg.append("groupId=");
15265                    msg.append(groupId);
15266    
15267                    msg.append(", folderId=");
15268                    msg.append(folderId);
15269    
15270                    msg.append(", status=");
15271                    msg.append(status);
15272    
15273                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15274    
15275                    throw new NoSuchArticleException(msg.toString());
15276            }
15277    
15278            /**
15279             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
15280             *
15281             * @param groupId the group ID
15282             * @param folderId the folder ID
15283             * @param status the status
15284             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15285             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
15286             * @throws SystemException if a system exception occurred
15287             */
15288            public JournalArticle fetchByG_F_ST_Last(long groupId, long folderId,
15289                    int status, OrderByComparator orderByComparator)
15290                    throws SystemException {
15291                    int count = countByG_F_ST(groupId, folderId, status);
15292    
15293                    List<JournalArticle> list = findByG_F_ST(groupId, folderId, status,
15294                                    count - 1, count, orderByComparator);
15295    
15296                    if (!list.isEmpty()) {
15297                            return list.get(0);
15298                    }
15299    
15300                    return null;
15301            }
15302    
15303            /**
15304             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
15305             *
15306             * @param id the primary key of the current journal article
15307             * @param groupId the group ID
15308             * @param folderId the folder ID
15309             * @param status the status
15310             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15311             * @return the previous, current, and next journal article
15312             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
15313             * @throws SystemException if a system exception occurred
15314             */
15315            public JournalArticle[] findByG_F_ST_PrevAndNext(long id, long groupId,
15316                    long folderId, int status, OrderByComparator orderByComparator)
15317                    throws NoSuchArticleException, SystemException {
15318                    JournalArticle journalArticle = findByPrimaryKey(id);
15319    
15320                    Session session = null;
15321    
15322                    try {
15323                            session = openSession();
15324    
15325                            JournalArticle[] array = new JournalArticleImpl[3];
15326    
15327                            array[0] = getByG_F_ST_PrevAndNext(session, journalArticle,
15328                                            groupId, folderId, status, orderByComparator, true);
15329    
15330                            array[1] = journalArticle;
15331    
15332                            array[2] = getByG_F_ST_PrevAndNext(session, journalArticle,
15333                                            groupId, folderId, status, orderByComparator, false);
15334    
15335                            return array;
15336                    }
15337                    catch (Exception e) {
15338                            throw processException(e);
15339                    }
15340                    finally {
15341                            closeSession(session);
15342                    }
15343            }
15344    
15345            protected JournalArticle getByG_F_ST_PrevAndNext(Session session,
15346                    JournalArticle journalArticle, long groupId, long folderId, int status,
15347                    OrderByComparator orderByComparator, boolean previous) {
15348                    StringBundler query = null;
15349    
15350                    if (orderByComparator != null) {
15351                            query = new StringBundler(6 +
15352                                            (orderByComparator.getOrderByFields().length * 6));
15353                    }
15354                    else {
15355                            query = new StringBundler(3);
15356                    }
15357    
15358                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15359    
15360                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
15361    
15362                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
15363    
15364                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
15365    
15366                    if (orderByComparator != null) {
15367                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15368    
15369                            if (orderByConditionFields.length > 0) {
15370                                    query.append(WHERE_AND);
15371                            }
15372    
15373                            for (int i = 0; i < orderByConditionFields.length; i++) {
15374                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15375                                    query.append(orderByConditionFields[i]);
15376    
15377                                    if ((i + 1) < orderByConditionFields.length) {
15378                                            if (orderByComparator.isAscending() ^ previous) {
15379                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15380                                            }
15381                                            else {
15382                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15383                                            }
15384                                    }
15385                                    else {
15386                                            if (orderByComparator.isAscending() ^ previous) {
15387                                                    query.append(WHERE_GREATER_THAN);
15388                                            }
15389                                            else {
15390                                                    query.append(WHERE_LESSER_THAN);
15391                                            }
15392                                    }
15393                            }
15394    
15395                            query.append(ORDER_BY_CLAUSE);
15396    
15397                            String[] orderByFields = orderByComparator.getOrderByFields();
15398    
15399                            for (int i = 0; i < orderByFields.length; i++) {
15400                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15401                                    query.append(orderByFields[i]);
15402    
15403                                    if ((i + 1) < orderByFields.length) {
15404                                            if (orderByComparator.isAscending() ^ previous) {
15405                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15406                                            }
15407                                            else {
15408                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15409                                            }
15410                                    }
15411                                    else {
15412                                            if (orderByComparator.isAscending() ^ previous) {
15413                                                    query.append(ORDER_BY_ASC);
15414                                            }
15415                                            else {
15416                                                    query.append(ORDER_BY_DESC);
15417                                            }
15418                                    }
15419                            }
15420                    }
15421                    else {
15422                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15423                    }
15424    
15425                    String sql = query.toString();
15426    
15427                    Query q = session.createQuery(sql);
15428    
15429                    q.setFirstResult(0);
15430                    q.setMaxResults(2);
15431    
15432                    QueryPos qPos = QueryPos.getInstance(q);
15433    
15434                    qPos.add(groupId);
15435    
15436                    qPos.add(folderId);
15437    
15438                    qPos.add(status);
15439    
15440                    if (orderByComparator != null) {
15441                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
15442    
15443                            for (Object value : values) {
15444                                    qPos.add(value);
15445                            }
15446                    }
15447    
15448                    List<JournalArticle> list = q.list();
15449    
15450                    if (list.size() == 2) {
15451                            return list.get(1);
15452                    }
15453                    else {
15454                            return null;
15455                    }
15456            }
15457    
15458            /**
15459             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
15460             *
15461             * @param groupId the group ID
15462             * @param folderId the folder ID
15463             * @param status the status
15464             * @return the matching journal articles that the user has permission to view
15465             * @throws SystemException if a system exception occurred
15466             */
15467            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
15468                    int status) throws SystemException {
15469                    return filterFindByG_F_ST(groupId, folderId, status, QueryUtil.ALL_POS,
15470                            QueryUtil.ALL_POS, null);
15471            }
15472    
15473            /**
15474             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
15475             *
15476             * <p>
15477             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15478             * </p>
15479             *
15480             * @param groupId the group ID
15481             * @param folderId the folder ID
15482             * @param status the status
15483             * @param start the lower bound of the range of journal articles
15484             * @param end the upper bound of the range of journal articles (not inclusive)
15485             * @return the range of matching journal articles that the user has permission to view
15486             * @throws SystemException if a system exception occurred
15487             */
15488            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
15489                    int status, int start, int end) throws SystemException {
15490                    return filterFindByG_F_ST(groupId, folderId, status, start, end, null);
15491            }
15492    
15493            /**
15494             * 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;.
15495             *
15496             * <p>
15497             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15498             * </p>
15499             *
15500             * @param groupId the group ID
15501             * @param folderId the folder ID
15502             * @param status the status
15503             * @param start the lower bound of the range of journal articles
15504             * @param end the upper bound of the range of journal articles (not inclusive)
15505             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15506             * @return the ordered range of matching journal articles that the user has permission to view
15507             * @throws SystemException if a system exception occurred
15508             */
15509            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
15510                    int status, int start, int end, OrderByComparator orderByComparator)
15511                    throws SystemException {
15512                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15513                            return findByG_F_ST(groupId, folderId, status, start, end,
15514                                    orderByComparator);
15515                    }
15516    
15517                    StringBundler query = null;
15518    
15519                    if (orderByComparator != null) {
15520                            query = new StringBundler(5 +
15521                                            (orderByComparator.getOrderByFields().length * 3));
15522                    }
15523                    else {
15524                            query = new StringBundler(5);
15525                    }
15526    
15527                    if (getDB().isSupportsInlineDistinct()) {
15528                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
15529                    }
15530                    else {
15531                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
15532                    }
15533    
15534                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
15535    
15536                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
15537    
15538                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
15539    
15540                    if (!getDB().isSupportsInlineDistinct()) {
15541                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
15542                    }
15543    
15544                    if (orderByComparator != null) {
15545                            if (getDB().isSupportsInlineDistinct()) {
15546                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15547                                            orderByComparator);
15548                            }
15549                            else {
15550                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
15551                                            orderByComparator);
15552                            }
15553                    }
15554                    else {
15555                            if (getDB().isSupportsInlineDistinct()) {
15556                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15557                            }
15558                            else {
15559                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
15560                            }
15561                    }
15562    
15563                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15564                                    JournalArticle.class.getName(),
15565                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15566    
15567                    Session session = null;
15568    
15569                    try {
15570                            session = openSession();
15571    
15572                            SQLQuery q = session.createSQLQuery(sql);
15573    
15574                            if (getDB().isSupportsInlineDistinct()) {
15575                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
15576                            }
15577                            else {
15578                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
15579                            }
15580    
15581                            QueryPos qPos = QueryPos.getInstance(q);
15582    
15583                            qPos.add(groupId);
15584    
15585                            qPos.add(folderId);
15586    
15587                            qPos.add(status);
15588    
15589                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
15590                                    end);
15591                    }
15592                    catch (Exception e) {
15593                            throw processException(e);
15594                    }
15595                    finally {
15596                            closeSession(session);
15597                    }
15598            }
15599    
15600            /**
15601             * 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;.
15602             *
15603             * @param id the primary key of the current journal article
15604             * @param groupId the group ID
15605             * @param folderId the folder ID
15606             * @param status the status
15607             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15608             * @return the previous, current, and next journal article
15609             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
15610             * @throws SystemException if a system exception occurred
15611             */
15612            public JournalArticle[] filterFindByG_F_ST_PrevAndNext(long id,
15613                    long groupId, long folderId, int status,
15614                    OrderByComparator orderByComparator)
15615                    throws NoSuchArticleException, SystemException {
15616                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15617                            return findByG_F_ST_PrevAndNext(id, groupId, folderId, status,
15618                                    orderByComparator);
15619                    }
15620    
15621                    JournalArticle journalArticle = findByPrimaryKey(id);
15622    
15623                    Session session = null;
15624    
15625                    try {
15626                            session = openSession();
15627    
15628                            JournalArticle[] array = new JournalArticleImpl[3];
15629    
15630                            array[0] = filterGetByG_F_ST_PrevAndNext(session, journalArticle,
15631                                            groupId, folderId, status, orderByComparator, true);
15632    
15633                            array[1] = journalArticle;
15634    
15635                            array[2] = filterGetByG_F_ST_PrevAndNext(session, journalArticle,
15636                                            groupId, folderId, status, orderByComparator, false);
15637    
15638                            return array;
15639                    }
15640                    catch (Exception e) {
15641                            throw processException(e);
15642                    }
15643                    finally {
15644                            closeSession(session);
15645                    }
15646            }
15647    
15648            protected JournalArticle filterGetByG_F_ST_PrevAndNext(Session session,
15649                    JournalArticle journalArticle, long groupId, long folderId, int status,
15650                    OrderByComparator orderByComparator, boolean previous) {
15651                    StringBundler query = null;
15652    
15653                    if (orderByComparator != null) {
15654                            query = new StringBundler(6 +
15655                                            (orderByComparator.getOrderByFields().length * 6));
15656                    }
15657                    else {
15658                            query = new StringBundler(3);
15659                    }
15660    
15661                    if (getDB().isSupportsInlineDistinct()) {
15662                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
15663                    }
15664                    else {
15665                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
15666                    }
15667    
15668                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
15669    
15670                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
15671    
15672                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
15673    
15674                    if (!getDB().isSupportsInlineDistinct()) {
15675                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
15676                    }
15677    
15678                    if (orderByComparator != null) {
15679                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15680    
15681                            if (orderByConditionFields.length > 0) {
15682                                    query.append(WHERE_AND);
15683                            }
15684    
15685                            for (int i = 0; i < orderByConditionFields.length; i++) {
15686                                    if (getDB().isSupportsInlineDistinct()) {
15687                                            query.append(_ORDER_BY_ENTITY_ALIAS);
15688                                    }
15689                                    else {
15690                                            query.append(_ORDER_BY_ENTITY_TABLE);
15691                                    }
15692    
15693                                    query.append(orderByConditionFields[i]);
15694    
15695                                    if ((i + 1) < orderByConditionFields.length) {
15696                                            if (orderByComparator.isAscending() ^ previous) {
15697                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15698                                            }
15699                                            else {
15700                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15701                                            }
15702                                    }
15703                                    else {
15704                                            if (orderByComparator.isAscending() ^ previous) {
15705                                                    query.append(WHERE_GREATER_THAN);
15706                                            }
15707                                            else {
15708                                                    query.append(WHERE_LESSER_THAN);
15709                                            }
15710                                    }
15711                            }
15712    
15713                            query.append(ORDER_BY_CLAUSE);
15714    
15715                            String[] orderByFields = orderByComparator.getOrderByFields();
15716    
15717                            for (int i = 0; i < orderByFields.length; i++) {
15718                                    if (getDB().isSupportsInlineDistinct()) {
15719                                            query.append(_ORDER_BY_ENTITY_ALIAS);
15720                                    }
15721                                    else {
15722                                            query.append(_ORDER_BY_ENTITY_TABLE);
15723                                    }
15724    
15725                                    query.append(orderByFields[i]);
15726    
15727                                    if ((i + 1) < orderByFields.length) {
15728                                            if (orderByComparator.isAscending() ^ previous) {
15729                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15730                                            }
15731                                            else {
15732                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15733                                            }
15734                                    }
15735                                    else {
15736                                            if (orderByComparator.isAscending() ^ previous) {
15737                                                    query.append(ORDER_BY_ASC);
15738                                            }
15739                                            else {
15740                                                    query.append(ORDER_BY_DESC);
15741                                            }
15742                                    }
15743                            }
15744                    }
15745                    else {
15746                            if (getDB().isSupportsInlineDistinct()) {
15747                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15748                            }
15749                            else {
15750                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
15751                            }
15752                    }
15753    
15754                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15755                                    JournalArticle.class.getName(),
15756                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15757    
15758                    SQLQuery q = session.createSQLQuery(sql);
15759    
15760                    q.setFirstResult(0);
15761                    q.setMaxResults(2);
15762    
15763                    if (getDB().isSupportsInlineDistinct()) {
15764                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
15765                    }
15766                    else {
15767                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
15768                    }
15769    
15770                    QueryPos qPos = QueryPos.getInstance(q);
15771    
15772                    qPos.add(groupId);
15773    
15774                    qPos.add(folderId);
15775    
15776                    qPos.add(status);
15777    
15778                    if (orderByComparator != null) {
15779                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
15780    
15781                            for (Object value : values) {
15782                                    qPos.add(value);
15783                            }
15784                    }
15785    
15786                    List<JournalArticle> list = q.list();
15787    
15788                    if (list.size() == 2) {
15789                            return list.get(1);
15790                    }
15791                    else {
15792                            return null;
15793                    }
15794            }
15795    
15796            /**
15797             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = any &#63;.
15798             *
15799             * @param groupId the group ID
15800             * @param folderId the folder ID
15801             * @param statuses the statuses
15802             * @return the matching journal articles that the user has permission to view
15803             * @throws SystemException if a system exception occurred
15804             */
15805            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
15806                    int[] statuses) throws SystemException {
15807                    return filterFindByG_F_ST(groupId, folderId, statuses,
15808                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
15809            }
15810    
15811            /**
15812             * 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;.
15813             *
15814             * <p>
15815             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15816             * </p>
15817             *
15818             * @param groupId the group ID
15819             * @param folderId the folder ID
15820             * @param statuses the statuses
15821             * @param start the lower bound of the range of journal articles
15822             * @param end the upper bound of the range of journal articles (not inclusive)
15823             * @return the range of matching journal articles that the user has permission to view
15824             * @throws SystemException if a system exception occurred
15825             */
15826            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
15827                    int[] statuses, int start, int end) throws SystemException {
15828                    return filterFindByG_F_ST(groupId, folderId, statuses, start, end, null);
15829            }
15830    
15831            /**
15832             * 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;.
15833             *
15834             * <p>
15835             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15836             * </p>
15837             *
15838             * @param groupId the group ID
15839             * @param folderId the folder ID
15840             * @param statuses the statuses
15841             * @param start the lower bound of the range of journal articles
15842             * @param end the upper bound of the range of journal articles (not inclusive)
15843             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15844             * @return the ordered range of matching journal articles that the user has permission to view
15845             * @throws SystemException if a system exception occurred
15846             */
15847            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
15848                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
15849                    throws SystemException {
15850                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15851                            return findByG_F_ST(groupId, folderId, statuses, start, end,
15852                                    orderByComparator);
15853                    }
15854    
15855                    StringBundler query = new StringBundler();
15856    
15857                    if (getDB().isSupportsInlineDistinct()) {
15858                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
15859                    }
15860                    else {
15861                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
15862                    }
15863    
15864                    boolean conjunctionable = false;
15865    
15866                    if (conjunctionable) {
15867                            query.append(WHERE_AND);
15868                    }
15869    
15870                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
15871    
15872                    conjunctionable = true;
15873    
15874                    if (conjunctionable) {
15875                            query.append(WHERE_AND);
15876                    }
15877    
15878                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
15879    
15880                    conjunctionable = true;
15881    
15882                    if ((statuses == null) || (statuses.length > 0)) {
15883                            if (conjunctionable) {
15884                                    query.append(WHERE_AND);
15885                            }
15886    
15887                            query.append(StringPool.OPEN_PARENTHESIS);
15888    
15889                            for (int i = 0; i < statuses.length; i++) {
15890                                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
15891    
15892                                    if ((i + 1) < statuses.length) {
15893                                            query.append(WHERE_OR);
15894                                    }
15895                            }
15896    
15897                            query.append(StringPool.CLOSE_PARENTHESIS);
15898    
15899                            conjunctionable = true;
15900                    }
15901    
15902                    if (!getDB().isSupportsInlineDistinct()) {
15903                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
15904                    }
15905    
15906                    if (orderByComparator != null) {
15907                            if (getDB().isSupportsInlineDistinct()) {
15908                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15909                                            orderByComparator);
15910                            }
15911                            else {
15912                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
15913                                            orderByComparator);
15914                            }
15915                    }
15916                    else {
15917                            if (getDB().isSupportsInlineDistinct()) {
15918                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15919                            }
15920                            else {
15921                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
15922                            }
15923                    }
15924    
15925                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15926                                    JournalArticle.class.getName(),
15927                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15928    
15929                    Session session = null;
15930    
15931                    try {
15932                            session = openSession();
15933    
15934                            SQLQuery q = session.createSQLQuery(sql);
15935    
15936                            if (getDB().isSupportsInlineDistinct()) {
15937                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
15938                            }
15939                            else {
15940                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
15941                            }
15942    
15943                            QueryPos qPos = QueryPos.getInstance(q);
15944    
15945                            qPos.add(groupId);
15946    
15947                            qPos.add(folderId);
15948    
15949                            if (statuses != null) {
15950                                    qPos.add(statuses);
15951                            }
15952    
15953                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
15954                                    end);
15955                    }
15956                    catch (Exception e) {
15957                            throw processException(e);
15958                    }
15959                    finally {
15960                            closeSession(session);
15961                    }
15962            }
15963    
15964            /**
15965             * Returns all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
15966             *
15967             * <p>
15968             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15969             * </p>
15970             *
15971             * @param groupId the group ID
15972             * @param folderId the folder ID
15973             * @param statuses the statuses
15974             * @return the matching journal articles
15975             * @throws SystemException if a system exception occurred
15976             */
15977            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
15978                    int[] statuses) throws SystemException {
15979                    return findByG_F_ST(groupId, folderId, statuses, QueryUtil.ALL_POS,
15980                            QueryUtil.ALL_POS, null);
15981            }
15982    
15983            /**
15984             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
15985             *
15986             * <p>
15987             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15988             * </p>
15989             *
15990             * @param groupId the group ID
15991             * @param folderId the folder ID
15992             * @param statuses the statuses
15993             * @param start the lower bound of the range of journal articles
15994             * @param end the upper bound of the range of journal articles (not inclusive)
15995             * @return the range of matching journal articles
15996             * @throws SystemException if a system exception occurred
15997             */
15998            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
15999                    int[] statuses, int start, int end) throws SystemException {
16000                    return findByG_F_ST(groupId, folderId, statuses, start, end, null);
16001            }
16002    
16003            /**
16004             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
16005             *
16006             * <p>
16007             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16008             * </p>
16009             *
16010             * @param groupId the group ID
16011             * @param folderId the folder ID
16012             * @param statuses the statuses
16013             * @param start the lower bound of the range of journal articles
16014             * @param end the upper bound of the range of journal articles (not inclusive)
16015             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16016             * @return the ordered range of matching journal articles
16017             * @throws SystemException if a system exception occurred
16018             */
16019            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
16020                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
16021                    throws SystemException {
16022                    if ((statuses != null) && (statuses.length == 1)) {
16023                            return findByG_F_ST(groupId, folderId, statuses[0], start, end,
16024                                    orderByComparator);
16025                    }
16026    
16027                    boolean pagination = true;
16028                    Object[] finderArgs = null;
16029    
16030                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
16031                                    (orderByComparator == null)) {
16032                            pagination = false;
16033                            finderArgs = new Object[] {
16034                                            groupId, folderId, StringUtil.merge(statuses)
16035                                    };
16036                    }
16037                    else {
16038                            finderArgs = new Object[] {
16039                                            groupId, folderId, StringUtil.merge(statuses),
16040                                            
16041                                            start, end, orderByComparator
16042                                    };
16043                    }
16044    
16045                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
16046                                    finderArgs, this);
16047    
16048                    if ((list != null) && !list.isEmpty()) {
16049                            for (JournalArticle journalArticle : list) {
16050                                    if ((groupId != journalArticle.getGroupId()) ||
16051                                                    (folderId != journalArticle.getFolderId()) ||
16052                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
16053                                            list = null;
16054    
16055                                            break;
16056                                    }
16057                            }
16058                    }
16059    
16060                    if (list == null) {
16061                            StringBundler query = new StringBundler();
16062    
16063                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16064    
16065                            boolean conjunctionable = false;
16066    
16067                            if (conjunctionable) {
16068                                    query.append(WHERE_AND);
16069                            }
16070    
16071                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
16072    
16073                            conjunctionable = true;
16074    
16075                            if (conjunctionable) {
16076                                    query.append(WHERE_AND);
16077                            }
16078    
16079                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
16080    
16081                            conjunctionable = true;
16082    
16083                            if ((statuses == null) || (statuses.length > 0)) {
16084                                    if (conjunctionable) {
16085                                            query.append(WHERE_AND);
16086                                    }
16087    
16088                                    query.append(StringPool.OPEN_PARENTHESIS);
16089    
16090                                    for (int i = 0; i < statuses.length; i++) {
16091                                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
16092    
16093                                            if ((i + 1) < statuses.length) {
16094                                                    query.append(WHERE_OR);
16095                                            }
16096                                    }
16097    
16098                                    query.append(StringPool.CLOSE_PARENTHESIS);
16099    
16100                                    conjunctionable = true;
16101                            }
16102    
16103                            if (orderByComparator != null) {
16104                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16105                                            orderByComparator);
16106                            }
16107                            else
16108                             if (pagination) {
16109                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16110                            }
16111    
16112                            String sql = query.toString();
16113    
16114                            Session session = null;
16115    
16116                            try {
16117                                    session = openSession();
16118    
16119                                    Query q = session.createQuery(sql);
16120    
16121                                    QueryPos qPos = QueryPos.getInstance(q);
16122    
16123                                    qPos.add(groupId);
16124    
16125                                    qPos.add(folderId);
16126    
16127                                    if (statuses != null) {
16128                                            qPos.add(statuses);
16129                                    }
16130    
16131                                    if (!pagination) {
16132                                            list = (List<JournalArticle>)QueryUtil.list(q,
16133                                                            getDialect(), start, end, false);
16134    
16135                                            Collections.sort(list);
16136    
16137                                            list = new UnmodifiableList<JournalArticle>(list);
16138                                    }
16139                                    else {
16140                                            list = (List<JournalArticle>)QueryUtil.list(q,
16141                                                            getDialect(), start, end);
16142                                    }
16143    
16144                                    cacheResult(list);
16145    
16146                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
16147                                            finderArgs, list);
16148                            }
16149                            catch (Exception e) {
16150                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
16151                                            finderArgs);
16152    
16153                                    throw processException(e);
16154                            }
16155                            finally {
16156                                    closeSession(session);
16157                            }
16158                    }
16159    
16160                    return list;
16161            }
16162    
16163            /**
16164             * Removes all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63; from the database.
16165             *
16166             * @param groupId the group ID
16167             * @param folderId the folder ID
16168             * @param status the status
16169             * @throws SystemException if a system exception occurred
16170             */
16171            public void removeByG_F_ST(long groupId, long folderId, int status)
16172                    throws SystemException {
16173                    for (JournalArticle journalArticle : findByG_F_ST(groupId, folderId,
16174                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
16175                            remove(journalArticle);
16176                    }
16177            }
16178    
16179            /**
16180             * Returns the number of journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
16181             *
16182             * @param groupId the group ID
16183             * @param folderId the folder ID
16184             * @param status the status
16185             * @return the number of matching journal articles
16186             * @throws SystemException if a system exception occurred
16187             */
16188            public int countByG_F_ST(long groupId, long folderId, int status)
16189                    throws SystemException {
16190                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F_ST;
16191    
16192                    Object[] finderArgs = new Object[] { groupId, folderId, status };
16193    
16194                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
16195                                    this);
16196    
16197                    if (count == null) {
16198                            StringBundler query = new StringBundler(4);
16199    
16200                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16201    
16202                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
16203    
16204                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
16205    
16206                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
16207    
16208                            String sql = query.toString();
16209    
16210                            Session session = null;
16211    
16212                            try {
16213                                    session = openSession();
16214    
16215                                    Query q = session.createQuery(sql);
16216    
16217                                    QueryPos qPos = QueryPos.getInstance(q);
16218    
16219                                    qPos.add(groupId);
16220    
16221                                    qPos.add(folderId);
16222    
16223                                    qPos.add(status);
16224    
16225                                    count = (Long)q.uniqueResult();
16226    
16227                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
16228                            }
16229                            catch (Exception e) {
16230                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16231    
16232                                    throw processException(e);
16233                            }
16234                            finally {
16235                                    closeSession(session);
16236                            }
16237                    }
16238    
16239                    return count.intValue();
16240            }
16241    
16242            /**
16243             * Returns the number of journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
16244             *
16245             * @param groupId the group ID
16246             * @param folderId the folder ID
16247             * @param statuses the statuses
16248             * @return the number of matching journal articles
16249             * @throws SystemException if a system exception occurred
16250             */
16251            public int countByG_F_ST(long groupId, long folderId, int[] statuses)
16252                    throws SystemException {
16253                    Object[] finderArgs = new Object[] {
16254                                    groupId, folderId, StringUtil.merge(statuses)
16255                            };
16256    
16257                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
16258                                    finderArgs, this);
16259    
16260                    if (count == null) {
16261                            StringBundler query = new StringBundler();
16262    
16263                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16264    
16265                            boolean conjunctionable = false;
16266    
16267                            if (conjunctionable) {
16268                                    query.append(WHERE_AND);
16269                            }
16270    
16271                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
16272    
16273                            conjunctionable = true;
16274    
16275                            if (conjunctionable) {
16276                                    query.append(WHERE_AND);
16277                            }
16278    
16279                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
16280    
16281                            conjunctionable = true;
16282    
16283                            if ((statuses == null) || (statuses.length > 0)) {
16284                                    if (conjunctionable) {
16285                                            query.append(WHERE_AND);
16286                                    }
16287    
16288                                    query.append(StringPool.OPEN_PARENTHESIS);
16289    
16290                                    for (int i = 0; i < statuses.length; i++) {
16291                                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
16292    
16293                                            if ((i + 1) < statuses.length) {
16294                                                    query.append(WHERE_OR);
16295                                            }
16296                                    }
16297    
16298                                    query.append(StringPool.CLOSE_PARENTHESIS);
16299    
16300                                    conjunctionable = true;
16301                            }
16302    
16303                            String sql = query.toString();
16304    
16305                            Session session = null;
16306    
16307                            try {
16308                                    session = openSession();
16309    
16310                                    Query q = session.createQuery(sql);
16311    
16312                                    QueryPos qPos = QueryPos.getInstance(q);
16313    
16314                                    qPos.add(groupId);
16315    
16316                                    qPos.add(folderId);
16317    
16318                                    if (statuses != null) {
16319                                            qPos.add(statuses);
16320                                    }
16321    
16322                                    count = (Long)q.uniqueResult();
16323    
16324                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
16325                                            finderArgs, count);
16326                            }
16327                            catch (Exception e) {
16328                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
16329                                            finderArgs);
16330    
16331                                    throw processException(e);
16332                            }
16333                            finally {
16334                                    closeSession(session);
16335                            }
16336                    }
16337    
16338                    return count.intValue();
16339            }
16340    
16341            /**
16342             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
16343             *
16344             * @param groupId the group ID
16345             * @param folderId the folder ID
16346             * @param status the status
16347             * @return the number of matching journal articles that the user has permission to view
16348             * @throws SystemException if a system exception occurred
16349             */
16350            public int filterCountByG_F_ST(long groupId, long folderId, int status)
16351                    throws SystemException {
16352                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16353                            return countByG_F_ST(groupId, folderId, status);
16354                    }
16355    
16356                    StringBundler query = new StringBundler(4);
16357    
16358                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
16359    
16360                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
16361    
16362                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
16363    
16364                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
16365    
16366                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16367                                    JournalArticle.class.getName(),
16368                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16369    
16370                    Session session = null;
16371    
16372                    try {
16373                            session = openSession();
16374    
16375                            SQLQuery q = session.createSQLQuery(sql);
16376    
16377                            q.addScalar(COUNT_COLUMN_NAME,
16378                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16379    
16380                            QueryPos qPos = QueryPos.getInstance(q);
16381    
16382                            qPos.add(groupId);
16383    
16384                            qPos.add(folderId);
16385    
16386                            qPos.add(status);
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            /**
16401             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = any &#63;.
16402             *
16403             * @param groupId the group ID
16404             * @param folderId the folder ID
16405             * @param statuses the statuses
16406             * @return the number of matching journal articles that the user has permission to view
16407             * @throws SystemException if a system exception occurred
16408             */
16409            public int filterCountByG_F_ST(long groupId, long folderId, int[] statuses)
16410                    throws SystemException {
16411                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16412                            return countByG_F_ST(groupId, folderId, statuses);
16413                    }
16414    
16415                    StringBundler query = new StringBundler();
16416    
16417                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
16418    
16419                    boolean conjunctionable = false;
16420    
16421                    if (conjunctionable) {
16422                            query.append(WHERE_AND);
16423                    }
16424    
16425                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
16426    
16427                    conjunctionable = true;
16428    
16429                    if (conjunctionable) {
16430                            query.append(WHERE_AND);
16431                    }
16432    
16433                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
16434    
16435                    conjunctionable = true;
16436    
16437                    if ((statuses == null) || (statuses.length > 0)) {
16438                            if (conjunctionable) {
16439                                    query.append(WHERE_AND);
16440                            }
16441    
16442                            query.append(StringPool.OPEN_PARENTHESIS);
16443    
16444                            for (int i = 0; i < statuses.length; i++) {
16445                                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
16446    
16447                                    if ((i + 1) < statuses.length) {
16448                                            query.append(WHERE_OR);
16449                                    }
16450                            }
16451    
16452                            query.append(StringPool.CLOSE_PARENTHESIS);
16453    
16454                            conjunctionable = true;
16455                    }
16456    
16457                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16458                                    JournalArticle.class.getName(),
16459                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16460    
16461                    Session session = null;
16462    
16463                    try {
16464                            session = openSession();
16465    
16466                            SQLQuery q = session.createSQLQuery(sql);
16467    
16468                            q.addScalar(COUNT_COLUMN_NAME,
16469                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16470    
16471                            QueryPos qPos = QueryPos.getInstance(q);
16472    
16473                            qPos.add(groupId);
16474    
16475                            qPos.add(folderId);
16476    
16477                            if (statuses != null) {
16478                                    qPos.add(statuses);
16479                            }
16480    
16481                            Long count = (Long)q.uniqueResult();
16482    
16483                            return count.intValue();
16484                    }
16485                    catch (Exception e) {
16486                            throw processException(e);
16487                    }
16488                    finally {
16489                            closeSession(session);
16490                    }
16491            }
16492    
16493            private static final String _FINDER_COLUMN_G_F_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
16494            private static final String _FINDER_COLUMN_G_F_ST_GROUPID_5 = "(" +
16495                    removeConjunction(_FINDER_COLUMN_G_F_ST_GROUPID_2) + ")";
16496            private static final String _FINDER_COLUMN_G_F_ST_FOLDERID_2 = "journalArticle.folderId = ? AND ";
16497            private static final String _FINDER_COLUMN_G_F_ST_FOLDERID_5 = "(" +
16498                    removeConjunction(_FINDER_COLUMN_G_F_ST_FOLDERID_2) + ")";
16499            private static final String _FINDER_COLUMN_G_F_ST_STATUS_2 = "journalArticle.status = ?";
16500            private static final String _FINDER_COLUMN_G_F_ST_STATUS_5 = "(" +
16501                    removeConjunction(_FINDER_COLUMN_G_F_ST_STATUS_2) + ")";
16502            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_NOTST =
16503                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16504                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
16505                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
16506                            "findByG_F_NotST",
16507                            new String[] {
16508                                    Long.class.getName(), Long.class.getName(),
16509                                    Integer.class.getName(),
16510                                    
16511                            Integer.class.getName(), Integer.class.getName(),
16512                                    OrderByComparator.class.getName()
16513                            });
16514            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_NOTST =
16515                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16516                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
16517                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F_NotST",
16518                            new String[] {
16519                                    Long.class.getName(), Long.class.getName(),
16520                                    Integer.class.getName()
16521                            });
16522    
16523            /**
16524             * Returns all the journal articles where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
16525             *
16526             * @param groupId the group ID
16527             * @param folderId the folder ID
16528             * @param status the status
16529             * @return the matching journal articles
16530             * @throws SystemException if a system exception occurred
16531             */
16532            public List<JournalArticle> findByG_F_NotST(long groupId, long folderId,
16533                    int status) throws SystemException {
16534                    return findByG_F_NotST(groupId, folderId, status, QueryUtil.ALL_POS,
16535                            QueryUtil.ALL_POS, null);
16536            }
16537    
16538            /**
16539             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
16540             *
16541             * <p>
16542             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16543             * </p>
16544             *
16545             * @param groupId the group ID
16546             * @param folderId the folder ID
16547             * @param status the status
16548             * @param start the lower bound of the range of journal articles
16549             * @param end the upper bound of the range of journal articles (not inclusive)
16550             * @return the range of matching journal articles
16551             * @throws SystemException if a system exception occurred
16552             */
16553            public List<JournalArticle> findByG_F_NotST(long groupId, long folderId,
16554                    int status, int start, int end) throws SystemException {
16555                    return findByG_F_NotST(groupId, folderId, status, start, end, null);
16556            }
16557    
16558            /**
16559             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
16560             *
16561             * <p>
16562             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16563             * </p>
16564             *
16565             * @param groupId the group ID
16566             * @param folderId the folder ID
16567             * @param status the status
16568             * @param start the lower bound of the range of journal articles
16569             * @param end the upper bound of the range of journal articles (not inclusive)
16570             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16571             * @return the ordered range of matching journal articles
16572             * @throws SystemException if a system exception occurred
16573             */
16574            public List<JournalArticle> findByG_F_NotST(long groupId, long folderId,
16575                    int status, int start, int end, OrderByComparator orderByComparator)
16576                    throws SystemException {
16577                    boolean pagination = true;
16578                    FinderPath finderPath = null;
16579                    Object[] finderArgs = null;
16580    
16581                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_NOTST;
16582                    finderArgs = new Object[] {
16583                                    groupId, folderId, status,
16584                                    
16585                                    start, end, orderByComparator
16586                            };
16587    
16588                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
16589                                    finderArgs, this);
16590    
16591                    if ((list != null) && !list.isEmpty()) {
16592                            for (JournalArticle journalArticle : list) {
16593                                    if ((groupId != journalArticle.getGroupId()) ||
16594                                                    (folderId != journalArticle.getFolderId()) ||
16595                                                    (status != journalArticle.getStatus())) {
16596                                            list = null;
16597    
16598                                            break;
16599                                    }
16600                            }
16601                    }
16602    
16603                    if (list == null) {
16604                            StringBundler query = null;
16605    
16606                            if (orderByComparator != null) {
16607                                    query = new StringBundler(5 +
16608                                                    (orderByComparator.getOrderByFields().length * 3));
16609                            }
16610                            else {
16611                                    query = new StringBundler(5);
16612                            }
16613    
16614                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16615    
16616                            query.append(_FINDER_COLUMN_G_F_NOTST_GROUPID_2);
16617    
16618                            query.append(_FINDER_COLUMN_G_F_NOTST_FOLDERID_2);
16619    
16620                            query.append(_FINDER_COLUMN_G_F_NOTST_STATUS_2);
16621    
16622                            if (orderByComparator != null) {
16623                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16624                                            orderByComparator);
16625                            }
16626                            else
16627                             if (pagination) {
16628                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16629                            }
16630    
16631                            String sql = query.toString();
16632    
16633                            Session session = null;
16634    
16635                            try {
16636                                    session = openSession();
16637    
16638                                    Query q = session.createQuery(sql);
16639    
16640                                    QueryPos qPos = QueryPos.getInstance(q);
16641    
16642                                    qPos.add(groupId);
16643    
16644                                    qPos.add(folderId);
16645    
16646                                    qPos.add(status);
16647    
16648                                    if (!pagination) {
16649                                            list = (List<JournalArticle>)QueryUtil.list(q,
16650                                                            getDialect(), start, end, false);
16651    
16652                                            Collections.sort(list);
16653    
16654                                            list = new UnmodifiableList<JournalArticle>(list);
16655                                    }
16656                                    else {
16657                                            list = (List<JournalArticle>)QueryUtil.list(q,
16658                                                            getDialect(), start, end);
16659                                    }
16660    
16661                                    cacheResult(list);
16662    
16663                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
16664                            }
16665                            catch (Exception e) {
16666                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16667    
16668                                    throw processException(e);
16669                            }
16670                            finally {
16671                                    closeSession(session);
16672                            }
16673                    }
16674    
16675                    return list;
16676            }
16677    
16678            /**
16679             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
16680             *
16681             * @param groupId the group ID
16682             * @param folderId the folder ID
16683             * @param status the status
16684             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16685             * @return the first matching journal article
16686             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
16687             * @throws SystemException if a system exception occurred
16688             */
16689            public JournalArticle findByG_F_NotST_First(long groupId, long folderId,
16690                    int status, OrderByComparator orderByComparator)
16691                    throws NoSuchArticleException, SystemException {
16692                    JournalArticle journalArticle = fetchByG_F_NotST_First(groupId,
16693                                    folderId, status, orderByComparator);
16694    
16695                    if (journalArticle != null) {
16696                            return journalArticle;
16697                    }
16698    
16699                    StringBundler msg = new StringBundler(8);
16700    
16701                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16702    
16703                    msg.append("groupId=");
16704                    msg.append(groupId);
16705    
16706                    msg.append(", folderId=");
16707                    msg.append(folderId);
16708    
16709                    msg.append(", status=");
16710                    msg.append(status);
16711    
16712                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16713    
16714                    throw new NoSuchArticleException(msg.toString());
16715            }
16716    
16717            /**
16718             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
16719             *
16720             * @param groupId the group ID
16721             * @param folderId the folder ID
16722             * @param status the status
16723             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16724             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
16725             * @throws SystemException if a system exception occurred
16726             */
16727            public JournalArticle fetchByG_F_NotST_First(long groupId, long folderId,
16728                    int status, OrderByComparator orderByComparator)
16729                    throws SystemException {
16730                    List<JournalArticle> list = findByG_F_NotST(groupId, folderId, status,
16731                                    0, 1, orderByComparator);
16732    
16733                    if (!list.isEmpty()) {
16734                            return list.get(0);
16735                    }
16736    
16737                    return null;
16738            }
16739    
16740            /**
16741             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
16742             *
16743             * @param groupId the group ID
16744             * @param folderId the folder ID
16745             * @param status the status
16746             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16747             * @return the last matching journal article
16748             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
16749             * @throws SystemException if a system exception occurred
16750             */
16751            public JournalArticle findByG_F_NotST_Last(long groupId, long folderId,
16752                    int status, OrderByComparator orderByComparator)
16753                    throws NoSuchArticleException, SystemException {
16754                    JournalArticle journalArticle = fetchByG_F_NotST_Last(groupId,
16755                                    folderId, status, orderByComparator);
16756    
16757                    if (journalArticle != null) {
16758                            return journalArticle;
16759                    }
16760    
16761                    StringBundler msg = new StringBundler(8);
16762    
16763                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16764    
16765                    msg.append("groupId=");
16766                    msg.append(groupId);
16767    
16768                    msg.append(", folderId=");
16769                    msg.append(folderId);
16770    
16771                    msg.append(", status=");
16772                    msg.append(status);
16773    
16774                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16775    
16776                    throw new NoSuchArticleException(msg.toString());
16777            }
16778    
16779            /**
16780             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
16781             *
16782             * @param groupId the group ID
16783             * @param folderId the folder ID
16784             * @param status the status
16785             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16786             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
16787             * @throws SystemException if a system exception occurred
16788             */
16789            public JournalArticle fetchByG_F_NotST_Last(long groupId, long folderId,
16790                    int status, OrderByComparator orderByComparator)
16791                    throws SystemException {
16792                    int count = countByG_F_NotST(groupId, folderId, status);
16793    
16794                    List<JournalArticle> list = findByG_F_NotST(groupId, folderId, status,
16795                                    count - 1, count, orderByComparator);
16796    
16797                    if (!list.isEmpty()) {
16798                            return list.get(0);
16799                    }
16800    
16801                    return null;
16802            }
16803    
16804            /**
16805             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
16806             *
16807             * @param id the primary key of the current journal article
16808             * @param groupId the group ID
16809             * @param folderId the folder ID
16810             * @param status the status
16811             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16812             * @return the previous, current, and next journal article
16813             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
16814             * @throws SystemException if a system exception occurred
16815             */
16816            public JournalArticle[] findByG_F_NotST_PrevAndNext(long id, long groupId,
16817                    long folderId, int status, OrderByComparator orderByComparator)
16818                    throws NoSuchArticleException, SystemException {
16819                    JournalArticle journalArticle = findByPrimaryKey(id);
16820    
16821                    Session session = null;
16822    
16823                    try {
16824                            session = openSession();
16825    
16826                            JournalArticle[] array = new JournalArticleImpl[3];
16827    
16828                            array[0] = getByG_F_NotST_PrevAndNext(session, journalArticle,
16829                                            groupId, folderId, status, orderByComparator, true);
16830    
16831                            array[1] = journalArticle;
16832    
16833                            array[2] = getByG_F_NotST_PrevAndNext(session, journalArticle,
16834                                            groupId, folderId, status, orderByComparator, false);
16835    
16836                            return array;
16837                    }
16838                    catch (Exception e) {
16839                            throw processException(e);
16840                    }
16841                    finally {
16842                            closeSession(session);
16843                    }
16844            }
16845    
16846            protected JournalArticle getByG_F_NotST_PrevAndNext(Session session,
16847                    JournalArticle journalArticle, long groupId, long folderId, int status,
16848                    OrderByComparator orderByComparator, boolean previous) {
16849                    StringBundler query = null;
16850    
16851                    if (orderByComparator != null) {
16852                            query = new StringBundler(6 +
16853                                            (orderByComparator.getOrderByFields().length * 6));
16854                    }
16855                    else {
16856                            query = new StringBundler(3);
16857                    }
16858    
16859                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16860    
16861                    query.append(_FINDER_COLUMN_G_F_NOTST_GROUPID_2);
16862    
16863                    query.append(_FINDER_COLUMN_G_F_NOTST_FOLDERID_2);
16864    
16865                    query.append(_FINDER_COLUMN_G_F_NOTST_STATUS_2);
16866    
16867                    if (orderByComparator != null) {
16868                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16869    
16870                            if (orderByConditionFields.length > 0) {
16871                                    query.append(WHERE_AND);
16872                            }
16873    
16874                            for (int i = 0; i < orderByConditionFields.length; i++) {
16875                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16876                                    query.append(orderByConditionFields[i]);
16877    
16878                                    if ((i + 1) < orderByConditionFields.length) {
16879                                            if (orderByComparator.isAscending() ^ previous) {
16880                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16881                                            }
16882                                            else {
16883                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16884                                            }
16885                                    }
16886                                    else {
16887                                            if (orderByComparator.isAscending() ^ previous) {
16888                                                    query.append(WHERE_GREATER_THAN);
16889                                            }
16890                                            else {
16891                                                    query.append(WHERE_LESSER_THAN);
16892                                            }
16893                                    }
16894                            }
16895    
16896                            query.append(ORDER_BY_CLAUSE);
16897    
16898                            String[] orderByFields = orderByComparator.getOrderByFields();
16899    
16900                            for (int i = 0; i < orderByFields.length; i++) {
16901                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16902                                    query.append(orderByFields[i]);
16903    
16904                                    if ((i + 1) < orderByFields.length) {
16905                                            if (orderByComparator.isAscending() ^ previous) {
16906                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16907                                            }
16908                                            else {
16909                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16910                                            }
16911                                    }
16912                                    else {
16913                                            if (orderByComparator.isAscending() ^ previous) {
16914                                                    query.append(ORDER_BY_ASC);
16915                                            }
16916                                            else {
16917                                                    query.append(ORDER_BY_DESC);
16918                                            }
16919                                    }
16920                            }
16921                    }
16922                    else {
16923                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16924                    }
16925    
16926                    String sql = query.toString();
16927    
16928                    Query q = session.createQuery(sql);
16929    
16930                    q.setFirstResult(0);
16931                    q.setMaxResults(2);
16932    
16933                    QueryPos qPos = QueryPos.getInstance(q);
16934    
16935                    qPos.add(groupId);
16936    
16937                    qPos.add(folderId);
16938    
16939                    qPos.add(status);
16940    
16941                    if (orderByComparator != null) {
16942                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
16943    
16944                            for (Object value : values) {
16945                                    qPos.add(value);
16946                            }
16947                    }
16948    
16949                    List<JournalArticle> list = q.list();
16950    
16951                    if (list.size() == 2) {
16952                            return list.get(1);
16953                    }
16954                    else {
16955                            return null;
16956                    }
16957            }
16958    
16959            /**
16960             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
16961             *
16962             * @param groupId the group ID
16963             * @param folderId the folder ID
16964             * @param status the status
16965             * @return the matching journal articles that the user has permission to view
16966             * @throws SystemException if a system exception occurred
16967             */
16968            public List<JournalArticle> filterFindByG_F_NotST(long groupId,
16969                    long folderId, int status) throws SystemException {
16970                    return filterFindByG_F_NotST(groupId, folderId, status,
16971                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
16972            }
16973    
16974            /**
16975             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
16976             *
16977             * <p>
16978             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16979             * </p>
16980             *
16981             * @param groupId the group ID
16982             * @param folderId the folder ID
16983             * @param status the status
16984             * @param start the lower bound of the range of journal articles
16985             * @param end the upper bound of the range of journal articles (not inclusive)
16986             * @return the range of matching journal articles that the user has permission to view
16987             * @throws SystemException if a system exception occurred
16988             */
16989            public List<JournalArticle> filterFindByG_F_NotST(long groupId,
16990                    long folderId, int status, int start, int end)
16991                    throws SystemException {
16992                    return filterFindByG_F_NotST(groupId, folderId, status, start, end, null);
16993            }
16994    
16995            /**
16996             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
16997             *
16998             * <p>
16999             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17000             * </p>
17001             *
17002             * @param groupId the group ID
17003             * @param folderId the folder ID
17004             * @param status the status
17005             * @param start the lower bound of the range of journal articles
17006             * @param end the upper bound of the range of journal articles (not inclusive)
17007             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17008             * @return the ordered range of matching journal articles that the user has permission to view
17009             * @throws SystemException if a system exception occurred
17010             */
17011            public List<JournalArticle> filterFindByG_F_NotST(long groupId,
17012                    long folderId, int status, int start, int end,
17013                    OrderByComparator orderByComparator) throws SystemException {
17014                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17015                            return findByG_F_NotST(groupId, folderId, status, start, end,
17016                                    orderByComparator);
17017                    }
17018    
17019                    StringBundler query = null;
17020    
17021                    if (orderByComparator != null) {
17022                            query = new StringBundler(5 +
17023                                            (orderByComparator.getOrderByFields().length * 3));
17024                    }
17025                    else {
17026                            query = new StringBundler(5);
17027                    }
17028    
17029                    if (getDB().isSupportsInlineDistinct()) {
17030                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
17031                    }
17032                    else {
17033                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
17034                    }
17035    
17036                    query.append(_FINDER_COLUMN_G_F_NOTST_GROUPID_2);
17037    
17038                    query.append(_FINDER_COLUMN_G_F_NOTST_FOLDERID_2);
17039    
17040                    query.append(_FINDER_COLUMN_G_F_NOTST_STATUS_2);
17041    
17042                    if (!getDB().isSupportsInlineDistinct()) {
17043                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
17044                    }
17045    
17046                    if (orderByComparator != null) {
17047                            if (getDB().isSupportsInlineDistinct()) {
17048                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17049                                            orderByComparator);
17050                            }
17051                            else {
17052                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
17053                                            orderByComparator);
17054                            }
17055                    }
17056                    else {
17057                            if (getDB().isSupportsInlineDistinct()) {
17058                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17059                            }
17060                            else {
17061                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
17062                            }
17063                    }
17064    
17065                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17066                                    JournalArticle.class.getName(),
17067                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17068    
17069                    Session session = null;
17070    
17071                    try {
17072                            session = openSession();
17073    
17074                            SQLQuery q = session.createSQLQuery(sql);
17075    
17076                            if (getDB().isSupportsInlineDistinct()) {
17077                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
17078                            }
17079                            else {
17080                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
17081                            }
17082    
17083                            QueryPos qPos = QueryPos.getInstance(q);
17084    
17085                            qPos.add(groupId);
17086    
17087                            qPos.add(folderId);
17088    
17089                            qPos.add(status);
17090    
17091                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
17092                                    end);
17093                    }
17094                    catch (Exception e) {
17095                            throw processException(e);
17096                    }
17097                    finally {
17098                            closeSession(session);
17099                    }
17100            }
17101    
17102            /**
17103             * 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 &ne; &#63;.
17104             *
17105             * @param id the primary key of the current journal article
17106             * @param groupId the group ID
17107             * @param folderId the folder ID
17108             * @param status the status
17109             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17110             * @return the previous, current, and next journal article
17111             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
17112             * @throws SystemException if a system exception occurred
17113             */
17114            public JournalArticle[] filterFindByG_F_NotST_PrevAndNext(long id,
17115                    long groupId, long folderId, int status,
17116                    OrderByComparator orderByComparator)
17117                    throws NoSuchArticleException, SystemException {
17118                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17119                            return findByG_F_NotST_PrevAndNext(id, groupId, folderId, status,
17120                                    orderByComparator);
17121                    }
17122    
17123                    JournalArticle journalArticle = findByPrimaryKey(id);
17124    
17125                    Session session = null;
17126    
17127                    try {
17128                            session = openSession();
17129    
17130                            JournalArticle[] array = new JournalArticleImpl[3];
17131    
17132                            array[0] = filterGetByG_F_NotST_PrevAndNext(session,
17133                                            journalArticle, groupId, folderId, status,
17134                                            orderByComparator, true);
17135    
17136                            array[1] = journalArticle;
17137    
17138                            array[2] = filterGetByG_F_NotST_PrevAndNext(session,
17139                                            journalArticle, groupId, folderId, status,
17140                                            orderByComparator, false);
17141    
17142                            return array;
17143                    }
17144                    catch (Exception e) {
17145                            throw processException(e);
17146                    }
17147                    finally {
17148                            closeSession(session);
17149                    }
17150            }
17151    
17152            protected JournalArticle filterGetByG_F_NotST_PrevAndNext(Session session,
17153                    JournalArticle journalArticle, long groupId, long folderId, int status,
17154                    OrderByComparator orderByComparator, boolean previous) {
17155                    StringBundler query = null;
17156    
17157                    if (orderByComparator != null) {
17158                            query = new StringBundler(6 +
17159                                            (orderByComparator.getOrderByFields().length * 6));
17160                    }
17161                    else {
17162                            query = new StringBundler(3);
17163                    }
17164    
17165                    if (getDB().isSupportsInlineDistinct()) {
17166                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
17167                    }
17168                    else {
17169                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
17170                    }
17171    
17172                    query.append(_FINDER_COLUMN_G_F_NOTST_GROUPID_2);
17173    
17174                    query.append(_FINDER_COLUMN_G_F_NOTST_FOLDERID_2);
17175    
17176                    query.append(_FINDER_COLUMN_G_F_NOTST_STATUS_2);
17177    
17178                    if (!getDB().isSupportsInlineDistinct()) {
17179                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
17180                    }
17181    
17182                    if (orderByComparator != null) {
17183                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17184    
17185                            if (orderByConditionFields.length > 0) {
17186                                    query.append(WHERE_AND);
17187                            }
17188    
17189                            for (int i = 0; i < orderByConditionFields.length; i++) {
17190                                    if (getDB().isSupportsInlineDistinct()) {
17191                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17192                                    }
17193                                    else {
17194                                            query.append(_ORDER_BY_ENTITY_TABLE);
17195                                    }
17196    
17197                                    query.append(orderByConditionFields[i]);
17198    
17199                                    if ((i + 1) < orderByConditionFields.length) {
17200                                            if (orderByComparator.isAscending() ^ previous) {
17201                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17202                                            }
17203                                            else {
17204                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17205                                            }
17206                                    }
17207                                    else {
17208                                            if (orderByComparator.isAscending() ^ previous) {
17209                                                    query.append(WHERE_GREATER_THAN);
17210                                            }
17211                                            else {
17212                                                    query.append(WHERE_LESSER_THAN);
17213                                            }
17214                                    }
17215                            }
17216    
17217                            query.append(ORDER_BY_CLAUSE);
17218    
17219                            String[] orderByFields = orderByComparator.getOrderByFields();
17220    
17221                            for (int i = 0; i < orderByFields.length; i++) {
17222                                    if (getDB().isSupportsInlineDistinct()) {
17223                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17224                                    }
17225                                    else {
17226                                            query.append(_ORDER_BY_ENTITY_TABLE);
17227                                    }
17228    
17229                                    query.append(orderByFields[i]);
17230    
17231                                    if ((i + 1) < orderByFields.length) {
17232                                            if (orderByComparator.isAscending() ^ previous) {
17233                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17234                                            }
17235                                            else {
17236                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17237                                            }
17238                                    }
17239                                    else {
17240                                            if (orderByComparator.isAscending() ^ previous) {
17241                                                    query.append(ORDER_BY_ASC);
17242                                            }
17243                                            else {
17244                                                    query.append(ORDER_BY_DESC);
17245                                            }
17246                                    }
17247                            }
17248                    }
17249                    else {
17250                            if (getDB().isSupportsInlineDistinct()) {
17251                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17252                            }
17253                            else {
17254                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
17255                            }
17256                    }
17257    
17258                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17259                                    JournalArticle.class.getName(),
17260                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17261    
17262                    SQLQuery q = session.createSQLQuery(sql);
17263    
17264                    q.setFirstResult(0);
17265                    q.setMaxResults(2);
17266    
17267                    if (getDB().isSupportsInlineDistinct()) {
17268                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
17269                    }
17270                    else {
17271                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
17272                    }
17273    
17274                    QueryPos qPos = QueryPos.getInstance(q);
17275    
17276                    qPos.add(groupId);
17277    
17278                    qPos.add(folderId);
17279    
17280                    qPos.add(status);
17281    
17282                    if (orderByComparator != null) {
17283                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
17284    
17285                            for (Object value : values) {
17286                                    qPos.add(value);
17287                            }
17288                    }
17289    
17290                    List<JournalArticle> list = q.list();
17291    
17292                    if (list.size() == 2) {
17293                            return list.get(1);
17294                    }
17295                    else {
17296                            return null;
17297                    }
17298            }
17299    
17300            /**
17301             * Removes all the journal articles where groupId = &#63; and folderId = &#63; and status &ne; &#63; from the database.
17302             *
17303             * @param groupId the group ID
17304             * @param folderId the folder ID
17305             * @param status the status
17306             * @throws SystemException if a system exception occurred
17307             */
17308            public void removeByG_F_NotST(long groupId, long folderId, int status)
17309                    throws SystemException {
17310                    for (JournalArticle journalArticle : findByG_F_NotST(groupId, folderId,
17311                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
17312                            remove(journalArticle);
17313                    }
17314            }
17315    
17316            /**
17317             * Returns the number of journal articles where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
17318             *
17319             * @param groupId the group ID
17320             * @param folderId the folder ID
17321             * @param status the status
17322             * @return the number of matching journal articles
17323             * @throws SystemException if a system exception occurred
17324             */
17325            public int countByG_F_NotST(long groupId, long folderId, int status)
17326                    throws SystemException {
17327                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_NOTST;
17328    
17329                    Object[] finderArgs = new Object[] { groupId, folderId, status };
17330    
17331                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
17332                                    this);
17333    
17334                    if (count == null) {
17335                            StringBundler query = new StringBundler(4);
17336    
17337                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17338    
17339                            query.append(_FINDER_COLUMN_G_F_NOTST_GROUPID_2);
17340    
17341                            query.append(_FINDER_COLUMN_G_F_NOTST_FOLDERID_2);
17342    
17343                            query.append(_FINDER_COLUMN_G_F_NOTST_STATUS_2);
17344    
17345                            String sql = query.toString();
17346    
17347                            Session session = null;
17348    
17349                            try {
17350                                    session = openSession();
17351    
17352                                    Query q = session.createQuery(sql);
17353    
17354                                    QueryPos qPos = QueryPos.getInstance(q);
17355    
17356                                    qPos.add(groupId);
17357    
17358                                    qPos.add(folderId);
17359    
17360                                    qPos.add(status);
17361    
17362                                    count = (Long)q.uniqueResult();
17363    
17364                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
17365                            }
17366                            catch (Exception e) {
17367                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17368    
17369                                    throw processException(e);
17370                            }
17371                            finally {
17372                                    closeSession(session);
17373                            }
17374                    }
17375    
17376                    return count.intValue();
17377            }
17378    
17379            /**
17380             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
17381             *
17382             * @param groupId the group ID
17383             * @param folderId the folder ID
17384             * @param status the status
17385             * @return the number of matching journal articles that the user has permission to view
17386             * @throws SystemException if a system exception occurred
17387             */
17388            public int filterCountByG_F_NotST(long groupId, long folderId, int status)
17389                    throws SystemException {
17390                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17391                            return countByG_F_NotST(groupId, folderId, status);
17392                    }
17393    
17394                    StringBundler query = new StringBundler(4);
17395    
17396                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
17397    
17398                    query.append(_FINDER_COLUMN_G_F_NOTST_GROUPID_2);
17399    
17400                    query.append(_FINDER_COLUMN_G_F_NOTST_FOLDERID_2);
17401    
17402                    query.append(_FINDER_COLUMN_G_F_NOTST_STATUS_2);
17403    
17404                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17405                                    JournalArticle.class.getName(),
17406                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17407    
17408                    Session session = null;
17409    
17410                    try {
17411                            session = openSession();
17412    
17413                            SQLQuery q = session.createSQLQuery(sql);
17414    
17415                            q.addScalar(COUNT_COLUMN_NAME,
17416                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17417    
17418                            QueryPos qPos = QueryPos.getInstance(q);
17419    
17420                            qPos.add(groupId);
17421    
17422                            qPos.add(folderId);
17423    
17424                            qPos.add(status);
17425    
17426                            Long count = (Long)q.uniqueResult();
17427    
17428                            return count.intValue();
17429                    }
17430                    catch (Exception e) {
17431                            throw processException(e);
17432                    }
17433                    finally {
17434                            closeSession(session);
17435                    }
17436            }
17437    
17438            private static final String _FINDER_COLUMN_G_F_NOTST_GROUPID_2 = "journalArticle.groupId = ? AND ";
17439            private static final String _FINDER_COLUMN_G_F_NOTST_FOLDERID_2 = "journalArticle.folderId = ? AND ";
17440            private static final String _FINDER_COLUMN_G_F_NOTST_STATUS_2 = "journalArticle.status != ?";
17441            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17442                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
17443                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
17444                            "findByG_C_C",
17445                            new String[] {
17446                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
17447                                    
17448                            Integer.class.getName(), Integer.class.getName(),
17449                                    OrderByComparator.class.getName()
17450                            });
17451            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17452                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
17453                            JournalArticleImpl.class,
17454                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_C",
17455                            new String[] {
17456                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
17457                            },
17458                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
17459                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
17460                            JournalArticleModelImpl.CLASSPK_COLUMN_BITMASK |
17461                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
17462                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
17463            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17464                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
17465                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_C",
17466                            new String[] {
17467                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
17468                            });
17469    
17470            /**
17471             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
17472             *
17473             * @param groupId the group ID
17474             * @param classNameId the class name ID
17475             * @param classPK the class p k
17476             * @return the matching journal articles
17477             * @throws SystemException if a system exception occurred
17478             */
17479            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
17480                    long classPK) throws SystemException {
17481                    return findByG_C_C(groupId, classNameId, classPK, QueryUtil.ALL_POS,
17482                            QueryUtil.ALL_POS, null);
17483            }
17484    
17485            /**
17486             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
17487             *
17488             * <p>
17489             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17490             * </p>
17491             *
17492             * @param groupId the group ID
17493             * @param classNameId the class name ID
17494             * @param classPK the class p k
17495             * @param start the lower bound of the range of journal articles
17496             * @param end the upper bound of the range of journal articles (not inclusive)
17497             * @return the range of matching journal articles
17498             * @throws SystemException if a system exception occurred
17499             */
17500            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
17501                    long classPK, int start, int end) throws SystemException {
17502                    return findByG_C_C(groupId, classNameId, classPK, start, end, null);
17503            }
17504    
17505            /**
17506             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
17507             *
17508             * <p>
17509             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17510             * </p>
17511             *
17512             * @param groupId the group ID
17513             * @param classNameId the class name ID
17514             * @param classPK the class p k
17515             * @param start the lower bound of the range of journal articles
17516             * @param end the upper bound of the range of journal articles (not inclusive)
17517             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17518             * @return the ordered range of matching journal articles
17519             * @throws SystemException if a system exception occurred
17520             */
17521            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
17522                    long classPK, int start, int end, OrderByComparator orderByComparator)
17523                    throws SystemException {
17524                    boolean pagination = true;
17525                    FinderPath finderPath = null;
17526                    Object[] finderArgs = null;
17527    
17528                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
17529                                    (orderByComparator == null)) {
17530                            pagination = false;
17531                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C;
17532                            finderArgs = new Object[] { groupId, classNameId, classPK };
17533                    }
17534                    else {
17535                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C;
17536                            finderArgs = new Object[] {
17537                                            groupId, classNameId, classPK,
17538                                            
17539                                            start, end, orderByComparator
17540                                    };
17541                    }
17542    
17543                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
17544                                    finderArgs, this);
17545    
17546                    if ((list != null) && !list.isEmpty()) {
17547                            for (JournalArticle journalArticle : list) {
17548                                    if ((groupId != journalArticle.getGroupId()) ||
17549                                                    (classNameId != journalArticle.getClassNameId()) ||
17550                                                    (classPK != journalArticle.getClassPK())) {
17551                                            list = null;
17552    
17553                                            break;
17554                                    }
17555                            }
17556                    }
17557    
17558                    if (list == null) {
17559                            StringBundler query = null;
17560    
17561                            if (orderByComparator != null) {
17562                                    query = new StringBundler(5 +
17563                                                    (orderByComparator.getOrderByFields().length * 3));
17564                            }
17565                            else {
17566                                    query = new StringBundler(5);
17567                            }
17568    
17569                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17570    
17571                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
17572    
17573                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
17574    
17575                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
17576    
17577                            if (orderByComparator != null) {
17578                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17579                                            orderByComparator);
17580                            }
17581                            else
17582                             if (pagination) {
17583                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17584                            }
17585    
17586                            String sql = query.toString();
17587    
17588                            Session session = null;
17589    
17590                            try {
17591                                    session = openSession();
17592    
17593                                    Query q = session.createQuery(sql);
17594    
17595                                    QueryPos qPos = QueryPos.getInstance(q);
17596    
17597                                    qPos.add(groupId);
17598    
17599                                    qPos.add(classNameId);
17600    
17601                                    qPos.add(classPK);
17602    
17603                                    if (!pagination) {
17604                                            list = (List<JournalArticle>)QueryUtil.list(q,
17605                                                            getDialect(), start, end, false);
17606    
17607                                            Collections.sort(list);
17608    
17609                                            list = new UnmodifiableList<JournalArticle>(list);
17610                                    }
17611                                    else {
17612                                            list = (List<JournalArticle>)QueryUtil.list(q,
17613                                                            getDialect(), start, end);
17614                                    }
17615    
17616                                    cacheResult(list);
17617    
17618                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
17619                            }
17620                            catch (Exception e) {
17621                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17622    
17623                                    throw processException(e);
17624                            }
17625                            finally {
17626                                    closeSession(session);
17627                            }
17628                    }
17629    
17630                    return list;
17631            }
17632    
17633            /**
17634             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
17635             *
17636             * @param groupId the group ID
17637             * @param classNameId the class name ID
17638             * @param classPK the class p k
17639             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17640             * @return the first matching journal article
17641             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
17642             * @throws SystemException if a system exception occurred
17643             */
17644            public JournalArticle findByG_C_C_First(long groupId, long classNameId,
17645                    long classPK, OrderByComparator orderByComparator)
17646                    throws NoSuchArticleException, SystemException {
17647                    JournalArticle journalArticle = fetchByG_C_C_First(groupId,
17648                                    classNameId, classPK, orderByComparator);
17649    
17650                    if (journalArticle != null) {
17651                            return journalArticle;
17652                    }
17653    
17654                    StringBundler msg = new StringBundler(8);
17655    
17656                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17657    
17658                    msg.append("groupId=");
17659                    msg.append(groupId);
17660    
17661                    msg.append(", classNameId=");
17662                    msg.append(classNameId);
17663    
17664                    msg.append(", classPK=");
17665                    msg.append(classPK);
17666    
17667                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17668    
17669                    throw new NoSuchArticleException(msg.toString());
17670            }
17671    
17672            /**
17673             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
17674             *
17675             * @param groupId the group ID
17676             * @param classNameId the class name ID
17677             * @param classPK the class p k
17678             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17679             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
17680             * @throws SystemException if a system exception occurred
17681             */
17682            public JournalArticle fetchByG_C_C_First(long groupId, long classNameId,
17683                    long classPK, OrderByComparator orderByComparator)
17684                    throws SystemException {
17685                    List<JournalArticle> list = findByG_C_C(groupId, classNameId, classPK,
17686                                    0, 1, orderByComparator);
17687    
17688                    if (!list.isEmpty()) {
17689                            return list.get(0);
17690                    }
17691    
17692                    return null;
17693            }
17694    
17695            /**
17696             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
17697             *
17698             * @param groupId the group ID
17699             * @param classNameId the class name ID
17700             * @param classPK the class p k
17701             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17702             * @return the last matching journal article
17703             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
17704             * @throws SystemException if a system exception occurred
17705             */
17706            public JournalArticle findByG_C_C_Last(long groupId, long classNameId,
17707                    long classPK, OrderByComparator orderByComparator)
17708                    throws NoSuchArticleException, SystemException {
17709                    JournalArticle journalArticle = fetchByG_C_C_Last(groupId, classNameId,
17710                                    classPK, orderByComparator);
17711    
17712                    if (journalArticle != null) {
17713                            return journalArticle;
17714                    }
17715    
17716                    StringBundler msg = new StringBundler(8);
17717    
17718                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17719    
17720                    msg.append("groupId=");
17721                    msg.append(groupId);
17722    
17723                    msg.append(", classNameId=");
17724                    msg.append(classNameId);
17725    
17726                    msg.append(", classPK=");
17727                    msg.append(classPK);
17728    
17729                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17730    
17731                    throw new NoSuchArticleException(msg.toString());
17732            }
17733    
17734            /**
17735             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
17736             *
17737             * @param groupId the group ID
17738             * @param classNameId the class name ID
17739             * @param classPK the class p k
17740             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17741             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
17742             * @throws SystemException if a system exception occurred
17743             */
17744            public JournalArticle fetchByG_C_C_Last(long groupId, long classNameId,
17745                    long classPK, OrderByComparator orderByComparator)
17746                    throws SystemException {
17747                    int count = countByG_C_C(groupId, classNameId, classPK);
17748    
17749                    List<JournalArticle> list = findByG_C_C(groupId, classNameId, classPK,
17750                                    count - 1, count, orderByComparator);
17751    
17752                    if (!list.isEmpty()) {
17753                            return list.get(0);
17754                    }
17755    
17756                    return null;
17757            }
17758    
17759            /**
17760             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
17761             *
17762             * @param id the primary key of the current journal article
17763             * @param groupId the group ID
17764             * @param classNameId the class name ID
17765             * @param classPK the class p k
17766             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17767             * @return the previous, current, and next journal article
17768             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
17769             * @throws SystemException if a system exception occurred
17770             */
17771            public JournalArticle[] findByG_C_C_PrevAndNext(long id, long groupId,
17772                    long classNameId, long classPK, OrderByComparator orderByComparator)
17773                    throws NoSuchArticleException, SystemException {
17774                    JournalArticle journalArticle = findByPrimaryKey(id);
17775    
17776                    Session session = null;
17777    
17778                    try {
17779                            session = openSession();
17780    
17781                            JournalArticle[] array = new JournalArticleImpl[3];
17782    
17783                            array[0] = getByG_C_C_PrevAndNext(session, journalArticle, groupId,
17784                                            classNameId, classPK, orderByComparator, true);
17785    
17786                            array[1] = journalArticle;
17787    
17788                            array[2] = getByG_C_C_PrevAndNext(session, journalArticle, groupId,
17789                                            classNameId, classPK, orderByComparator, false);
17790    
17791                            return array;
17792                    }
17793                    catch (Exception e) {
17794                            throw processException(e);
17795                    }
17796                    finally {
17797                            closeSession(session);
17798                    }
17799            }
17800    
17801            protected JournalArticle getByG_C_C_PrevAndNext(Session session,
17802                    JournalArticle journalArticle, long groupId, long classNameId,
17803                    long classPK, OrderByComparator orderByComparator, boolean previous) {
17804                    StringBundler query = null;
17805    
17806                    if (orderByComparator != null) {
17807                            query = new StringBundler(6 +
17808                                            (orderByComparator.getOrderByFields().length * 6));
17809                    }
17810                    else {
17811                            query = new StringBundler(3);
17812                    }
17813    
17814                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17815    
17816                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
17817    
17818                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
17819    
17820                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
17821    
17822                    if (orderByComparator != null) {
17823                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17824    
17825                            if (orderByConditionFields.length > 0) {
17826                                    query.append(WHERE_AND);
17827                            }
17828    
17829                            for (int i = 0; i < orderByConditionFields.length; i++) {
17830                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17831                                    query.append(orderByConditionFields[i]);
17832    
17833                                    if ((i + 1) < orderByConditionFields.length) {
17834                                            if (orderByComparator.isAscending() ^ previous) {
17835                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17836                                            }
17837                                            else {
17838                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17839                                            }
17840                                    }
17841                                    else {
17842                                            if (orderByComparator.isAscending() ^ previous) {
17843                                                    query.append(WHERE_GREATER_THAN);
17844                                            }
17845                                            else {
17846                                                    query.append(WHERE_LESSER_THAN);
17847                                            }
17848                                    }
17849                            }
17850    
17851                            query.append(ORDER_BY_CLAUSE);
17852    
17853                            String[] orderByFields = orderByComparator.getOrderByFields();
17854    
17855                            for (int i = 0; i < orderByFields.length; i++) {
17856                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17857                                    query.append(orderByFields[i]);
17858    
17859                                    if ((i + 1) < orderByFields.length) {
17860                                            if (orderByComparator.isAscending() ^ previous) {
17861                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17862                                            }
17863                                            else {
17864                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17865                                            }
17866                                    }
17867                                    else {
17868                                            if (orderByComparator.isAscending() ^ previous) {
17869                                                    query.append(ORDER_BY_ASC);
17870                                            }
17871                                            else {
17872                                                    query.append(ORDER_BY_DESC);
17873                                            }
17874                                    }
17875                            }
17876                    }
17877                    else {
17878                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17879                    }
17880    
17881                    String sql = query.toString();
17882    
17883                    Query q = session.createQuery(sql);
17884    
17885                    q.setFirstResult(0);
17886                    q.setMaxResults(2);
17887    
17888                    QueryPos qPos = QueryPos.getInstance(q);
17889    
17890                    qPos.add(groupId);
17891    
17892                    qPos.add(classNameId);
17893    
17894                    qPos.add(classPK);
17895    
17896                    if (orderByComparator != null) {
17897                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
17898    
17899                            for (Object value : values) {
17900                                    qPos.add(value);
17901                            }
17902                    }
17903    
17904                    List<JournalArticle> list = q.list();
17905    
17906                    if (list.size() == 2) {
17907                            return list.get(1);
17908                    }
17909                    else {
17910                            return null;
17911                    }
17912            }
17913    
17914            /**
17915             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
17916             *
17917             * @param groupId the group ID
17918             * @param classNameId the class name ID
17919             * @param classPK the class p k
17920             * @return the matching journal articles that the user has permission to view
17921             * @throws SystemException if a system exception occurred
17922             */
17923            public List<JournalArticle> filterFindByG_C_C(long groupId,
17924                    long classNameId, long classPK) throws SystemException {
17925                    return filterFindByG_C_C(groupId, classNameId, classPK,
17926                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
17927            }
17928    
17929            /**
17930             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
17931             *
17932             * <p>
17933             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17934             * </p>
17935             *
17936             * @param groupId the group ID
17937             * @param classNameId the class name ID
17938             * @param classPK the class p k
17939             * @param start the lower bound of the range of journal articles
17940             * @param end the upper bound of the range of journal articles (not inclusive)
17941             * @return the range of matching journal articles that the user has permission to view
17942             * @throws SystemException if a system exception occurred
17943             */
17944            public List<JournalArticle> filterFindByG_C_C(long groupId,
17945                    long classNameId, long classPK, int start, int end)
17946                    throws SystemException {
17947                    return filterFindByG_C_C(groupId, classNameId, classPK, start, end, null);
17948            }
17949    
17950            /**
17951             * 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;.
17952             *
17953             * <p>
17954             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17955             * </p>
17956             *
17957             * @param groupId the group ID
17958             * @param classNameId the class name ID
17959             * @param classPK the class p k
17960             * @param start the lower bound of the range of journal articles
17961             * @param end the upper bound of the range of journal articles (not inclusive)
17962             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17963             * @return the ordered range of matching journal articles that the user has permission to view
17964             * @throws SystemException if a system exception occurred
17965             */
17966            public List<JournalArticle> filterFindByG_C_C(long groupId,
17967                    long classNameId, long classPK, int start, int end,
17968                    OrderByComparator orderByComparator) throws SystemException {
17969                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17970                            return findByG_C_C(groupId, classNameId, classPK, start, end,
17971                                    orderByComparator);
17972                    }
17973    
17974                    StringBundler query = null;
17975    
17976                    if (orderByComparator != null) {
17977                            query = new StringBundler(5 +
17978                                            (orderByComparator.getOrderByFields().length * 3));
17979                    }
17980                    else {
17981                            query = new StringBundler(5);
17982                    }
17983    
17984                    if (getDB().isSupportsInlineDistinct()) {
17985                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
17986                    }
17987                    else {
17988                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
17989                    }
17990    
17991                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
17992    
17993                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
17994    
17995                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
17996    
17997                    if (!getDB().isSupportsInlineDistinct()) {
17998                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
17999                    }
18000    
18001                    if (orderByComparator != null) {
18002                            if (getDB().isSupportsInlineDistinct()) {
18003                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18004                                            orderByComparator);
18005                            }
18006                            else {
18007                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
18008                                            orderByComparator);
18009                            }
18010                    }
18011                    else {
18012                            if (getDB().isSupportsInlineDistinct()) {
18013                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18014                            }
18015                            else {
18016                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
18017                            }
18018                    }
18019    
18020                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18021                                    JournalArticle.class.getName(),
18022                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18023    
18024                    Session session = null;
18025    
18026                    try {
18027                            session = openSession();
18028    
18029                            SQLQuery q = session.createSQLQuery(sql);
18030    
18031                            if (getDB().isSupportsInlineDistinct()) {
18032                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
18033                            }
18034                            else {
18035                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
18036                            }
18037    
18038                            QueryPos qPos = QueryPos.getInstance(q);
18039    
18040                            qPos.add(groupId);
18041    
18042                            qPos.add(classNameId);
18043    
18044                            qPos.add(classPK);
18045    
18046                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
18047                                    end);
18048                    }
18049                    catch (Exception e) {
18050                            throw processException(e);
18051                    }
18052                    finally {
18053                            closeSession(session);
18054                    }
18055            }
18056    
18057            /**
18058             * 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;.
18059             *
18060             * @param id the primary key of the current journal article
18061             * @param groupId the group ID
18062             * @param classNameId the class name ID
18063             * @param classPK the class p k
18064             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18065             * @return the previous, current, and next journal article
18066             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
18067             * @throws SystemException if a system exception occurred
18068             */
18069            public JournalArticle[] filterFindByG_C_C_PrevAndNext(long id,
18070                    long groupId, long classNameId, long classPK,
18071                    OrderByComparator orderByComparator)
18072                    throws NoSuchArticleException, SystemException {
18073                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18074                            return findByG_C_C_PrevAndNext(id, groupId, classNameId, classPK,
18075                                    orderByComparator);
18076                    }
18077    
18078                    JournalArticle journalArticle = findByPrimaryKey(id);
18079    
18080                    Session session = null;
18081    
18082                    try {
18083                            session = openSession();
18084    
18085                            JournalArticle[] array = new JournalArticleImpl[3];
18086    
18087                            array[0] = filterGetByG_C_C_PrevAndNext(session, journalArticle,
18088                                            groupId, classNameId, classPK, orderByComparator, true);
18089    
18090                            array[1] = journalArticle;
18091    
18092                            array[2] = filterGetByG_C_C_PrevAndNext(session, journalArticle,
18093                                            groupId, classNameId, classPK, orderByComparator, false);
18094    
18095                            return array;
18096                    }
18097                    catch (Exception e) {
18098                            throw processException(e);
18099                    }
18100                    finally {
18101                            closeSession(session);
18102                    }
18103            }
18104    
18105            protected JournalArticle filterGetByG_C_C_PrevAndNext(Session session,
18106                    JournalArticle journalArticle, long groupId, long classNameId,
18107                    long classPK, OrderByComparator orderByComparator, boolean previous) {
18108                    StringBundler query = null;
18109    
18110                    if (orderByComparator != null) {
18111                            query = new StringBundler(6 +
18112                                            (orderByComparator.getOrderByFields().length * 6));
18113                    }
18114                    else {
18115                            query = new StringBundler(3);
18116                    }
18117    
18118                    if (getDB().isSupportsInlineDistinct()) {
18119                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
18120                    }
18121                    else {
18122                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
18123                    }
18124    
18125                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
18126    
18127                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
18128    
18129                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
18130    
18131                    if (!getDB().isSupportsInlineDistinct()) {
18132                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
18133                    }
18134    
18135                    if (orderByComparator != null) {
18136                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
18137    
18138                            if (orderByConditionFields.length > 0) {
18139                                    query.append(WHERE_AND);
18140                            }
18141    
18142                            for (int i = 0; i < orderByConditionFields.length; i++) {
18143                                    if (getDB().isSupportsInlineDistinct()) {
18144                                            query.append(_ORDER_BY_ENTITY_ALIAS);
18145                                    }
18146                                    else {
18147                                            query.append(_ORDER_BY_ENTITY_TABLE);
18148                                    }
18149    
18150                                    query.append(orderByConditionFields[i]);
18151    
18152                                    if ((i + 1) < orderByConditionFields.length) {
18153                                            if (orderByComparator.isAscending() ^ previous) {
18154                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
18155                                            }
18156                                            else {
18157                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
18158                                            }
18159                                    }
18160                                    else {
18161                                            if (orderByComparator.isAscending() ^ previous) {
18162                                                    query.append(WHERE_GREATER_THAN);
18163                                            }
18164                                            else {
18165                                                    query.append(WHERE_LESSER_THAN);
18166                                            }
18167                                    }
18168                            }
18169    
18170                            query.append(ORDER_BY_CLAUSE);
18171    
18172                            String[] orderByFields = orderByComparator.getOrderByFields();
18173    
18174                            for (int i = 0; i < orderByFields.length; i++) {
18175                                    if (getDB().isSupportsInlineDistinct()) {
18176                                            query.append(_ORDER_BY_ENTITY_ALIAS);
18177                                    }
18178                                    else {
18179                                            query.append(_ORDER_BY_ENTITY_TABLE);
18180                                    }
18181    
18182                                    query.append(orderByFields[i]);
18183    
18184                                    if ((i + 1) < orderByFields.length) {
18185                                            if (orderByComparator.isAscending() ^ previous) {
18186                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
18187                                            }
18188                                            else {
18189                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
18190                                            }
18191                                    }
18192                                    else {
18193                                            if (orderByComparator.isAscending() ^ previous) {
18194                                                    query.append(ORDER_BY_ASC);
18195                                            }
18196                                            else {
18197                                                    query.append(ORDER_BY_DESC);
18198                                            }
18199                                    }
18200                            }
18201                    }
18202                    else {
18203                            if (getDB().isSupportsInlineDistinct()) {
18204                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18205                            }
18206                            else {
18207                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
18208                            }
18209                    }
18210    
18211                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18212                                    JournalArticle.class.getName(),
18213                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18214    
18215                    SQLQuery q = session.createSQLQuery(sql);
18216    
18217                    q.setFirstResult(0);
18218                    q.setMaxResults(2);
18219    
18220                    if (getDB().isSupportsInlineDistinct()) {
18221                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
18222                    }
18223                    else {
18224                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
18225                    }
18226    
18227                    QueryPos qPos = QueryPos.getInstance(q);
18228    
18229                    qPos.add(groupId);
18230    
18231                    qPos.add(classNameId);
18232    
18233                    qPos.add(classPK);
18234    
18235                    if (orderByComparator != null) {
18236                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
18237    
18238                            for (Object value : values) {
18239                                    qPos.add(value);
18240                            }
18241                    }
18242    
18243                    List<JournalArticle> list = q.list();
18244    
18245                    if (list.size() == 2) {
18246                            return list.get(1);
18247                    }
18248                    else {
18249                            return null;
18250                    }
18251            }
18252    
18253            /**
18254             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63; from the database.
18255             *
18256             * @param groupId the group ID
18257             * @param classNameId the class name ID
18258             * @param classPK the class p k
18259             * @throws SystemException if a system exception occurred
18260             */
18261            public void removeByG_C_C(long groupId, long classNameId, long classPK)
18262                    throws SystemException {
18263                    for (JournalArticle journalArticle : findByG_C_C(groupId, classNameId,
18264                                    classPK, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
18265                            remove(journalArticle);
18266                    }
18267            }
18268    
18269            /**
18270             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
18271             *
18272             * @param groupId the group ID
18273             * @param classNameId the class name ID
18274             * @param classPK the class p k
18275             * @return the number of matching journal articles
18276             * @throws SystemException if a system exception occurred
18277             */
18278            public int countByG_C_C(long groupId, long classNameId, long classPK)
18279                    throws SystemException {
18280                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_C;
18281    
18282                    Object[] finderArgs = new Object[] { groupId, classNameId, classPK };
18283    
18284                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
18285                                    this);
18286    
18287                    if (count == null) {
18288                            StringBundler query = new StringBundler(4);
18289    
18290                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
18291    
18292                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
18293    
18294                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
18295    
18296                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
18297    
18298                            String sql = query.toString();
18299    
18300                            Session session = null;
18301    
18302                            try {
18303                                    session = openSession();
18304    
18305                                    Query q = session.createQuery(sql);
18306    
18307                                    QueryPos qPos = QueryPos.getInstance(q);
18308    
18309                                    qPos.add(groupId);
18310    
18311                                    qPos.add(classNameId);
18312    
18313                                    qPos.add(classPK);
18314    
18315                                    count = (Long)q.uniqueResult();
18316    
18317                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
18318                            }
18319                            catch (Exception e) {
18320                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18321    
18322                                    throw processException(e);
18323                            }
18324                            finally {
18325                                    closeSession(session);
18326                            }
18327                    }
18328    
18329                    return count.intValue();
18330            }
18331    
18332            /**
18333             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
18334             *
18335             * @param groupId the group ID
18336             * @param classNameId the class name ID
18337             * @param classPK the class p k
18338             * @return the number of matching journal articles that the user has permission to view
18339             * @throws SystemException if a system exception occurred
18340             */
18341            public int filterCountByG_C_C(long groupId, long classNameId, long classPK)
18342                    throws SystemException {
18343                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18344                            return countByG_C_C(groupId, classNameId, classPK);
18345                    }
18346    
18347                    StringBundler query = new StringBundler(4);
18348    
18349                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
18350    
18351                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
18352    
18353                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
18354    
18355                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
18356    
18357                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18358                                    JournalArticle.class.getName(),
18359                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18360    
18361                    Session session = null;
18362    
18363                    try {
18364                            session = openSession();
18365    
18366                            SQLQuery q = session.createSQLQuery(sql);
18367    
18368                            q.addScalar(COUNT_COLUMN_NAME,
18369                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
18370    
18371                            QueryPos qPos = QueryPos.getInstance(q);
18372    
18373                            qPos.add(groupId);
18374    
18375                            qPos.add(classNameId);
18376    
18377                            qPos.add(classPK);
18378    
18379                            Long count = (Long)q.uniqueResult();
18380    
18381                            return count.intValue();
18382                    }
18383                    catch (Exception e) {
18384                            throw processException(e);
18385                    }
18386                    finally {
18387                            closeSession(session);
18388                    }
18389            }
18390    
18391            private static final String _FINDER_COLUMN_G_C_C_GROUPID_2 = "journalArticle.groupId = ? AND ";
18392            private static final String _FINDER_COLUMN_G_C_C_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
18393            private static final String _FINDER_COLUMN_G_C_C_CLASSPK_2 = "journalArticle.classPK = ?";
18394            public static final FinderPath FINDER_PATH_FETCH_BY_G_C_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18395                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
18396                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_C_S",
18397                            new String[] {
18398                                    Long.class.getName(), Long.class.getName(),
18399                                    String.class.getName()
18400                            },
18401                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
18402                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
18403                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK);
18404            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18405                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
18406                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_S",
18407                            new String[] {
18408                                    Long.class.getName(), Long.class.getName(),
18409                                    String.class.getName()
18410                            });
18411    
18412            /**
18413             * 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.
18414             *
18415             * @param groupId the group ID
18416             * @param classNameId the class name ID
18417             * @param structureId the structure ID
18418             * @return the matching journal article
18419             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
18420             * @throws SystemException if a system exception occurred
18421             */
18422            public JournalArticle findByG_C_S(long groupId, long classNameId,
18423                    String structureId) throws NoSuchArticleException, SystemException {
18424                    JournalArticle journalArticle = fetchByG_C_S(groupId, classNameId,
18425                                    structureId);
18426    
18427                    if (journalArticle == null) {
18428                            StringBundler msg = new StringBundler(8);
18429    
18430                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
18431    
18432                            msg.append("groupId=");
18433                            msg.append(groupId);
18434    
18435                            msg.append(", classNameId=");
18436                            msg.append(classNameId);
18437    
18438                            msg.append(", structureId=");
18439                            msg.append(structureId);
18440    
18441                            msg.append(StringPool.CLOSE_CURLY_BRACE);
18442    
18443                            if (_log.isWarnEnabled()) {
18444                                    _log.warn(msg.toString());
18445                            }
18446    
18447                            throw new NoSuchArticleException(msg.toString());
18448                    }
18449    
18450                    return journalArticle;
18451            }
18452    
18453            /**
18454             * 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.
18455             *
18456             * @param groupId the group ID
18457             * @param classNameId the class name ID
18458             * @param structureId the structure ID
18459             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
18460             * @throws SystemException if a system exception occurred
18461             */
18462            public JournalArticle fetchByG_C_S(long groupId, long classNameId,
18463                    String structureId) throws SystemException {
18464                    return fetchByG_C_S(groupId, classNameId, structureId, true);
18465            }
18466    
18467            /**
18468             * 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.
18469             *
18470             * @param groupId the group ID
18471             * @param classNameId the class name ID
18472             * @param structureId the structure ID
18473             * @param retrieveFromCache whether to use the finder cache
18474             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
18475             * @throws SystemException if a system exception occurred
18476             */
18477            public JournalArticle fetchByG_C_S(long groupId, long classNameId,
18478                    String structureId, boolean retrieveFromCache)
18479                    throws SystemException {
18480                    Object[] finderArgs = new Object[] { groupId, classNameId, structureId };
18481    
18482                    Object result = null;
18483    
18484                    if (retrieveFromCache) {
18485                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_C_S,
18486                                            finderArgs, this);
18487                    }
18488    
18489                    if (result instanceof JournalArticle) {
18490                            JournalArticle journalArticle = (JournalArticle)result;
18491    
18492                            if ((groupId != journalArticle.getGroupId()) ||
18493                                            (classNameId != journalArticle.getClassNameId()) ||
18494                                            !Validator.equals(structureId,
18495                                                    journalArticle.getStructureId())) {
18496                                    result = null;
18497                            }
18498                    }
18499    
18500                    if (result == null) {
18501                            StringBundler query = new StringBundler(5);
18502    
18503                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
18504    
18505                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
18506    
18507                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
18508    
18509                            boolean bindStructureId = false;
18510    
18511                            if (structureId == null) {
18512                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_1);
18513                            }
18514                            else if (structureId.equals(StringPool.BLANK)) {
18515                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_3);
18516                            }
18517                            else {
18518                                    bindStructureId = true;
18519    
18520                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_2);
18521                            }
18522    
18523                            String sql = query.toString();
18524    
18525                            Session session = null;
18526    
18527                            try {
18528                                    session = openSession();
18529    
18530                                    Query q = session.createQuery(sql);
18531    
18532                                    QueryPos qPos = QueryPos.getInstance(q);
18533    
18534                                    qPos.add(groupId);
18535    
18536                                    qPos.add(classNameId);
18537    
18538                                    if (bindStructureId) {
18539                                            qPos.add(structureId);
18540                                    }
18541    
18542                                    List<JournalArticle> list = q.list();
18543    
18544                                    if (list.isEmpty()) {
18545                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
18546                                                    finderArgs, list);
18547                                    }
18548                                    else {
18549                                            if ((list.size() > 1) && _log.isWarnEnabled()) {
18550                                                    _log.warn(
18551                                                            "JournalArticlePersistenceImpl.fetchByG_C_S(long, long, String, boolean) with parameters (" +
18552                                                            StringUtil.merge(finderArgs) +
18553                                                            ") 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.");
18554                                            }
18555    
18556                                            JournalArticle journalArticle = list.get(0);
18557    
18558                                            result = journalArticle;
18559    
18560                                            cacheResult(journalArticle);
18561    
18562                                            if ((journalArticle.getGroupId() != groupId) ||
18563                                                            (journalArticle.getClassNameId() != classNameId) ||
18564                                                            (journalArticle.getStructureId() == null) ||
18565                                                            !journalArticle.getStructureId().equals(structureId)) {
18566                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
18567                                                            finderArgs, journalArticle);
18568                                            }
18569                                    }
18570                            }
18571                            catch (Exception e) {
18572                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S,
18573                                            finderArgs);
18574    
18575                                    throw processException(e);
18576                            }
18577                            finally {
18578                                    closeSession(session);
18579                            }
18580                    }
18581    
18582                    if (result instanceof List<?>) {
18583                            return null;
18584                    }
18585                    else {
18586                            return (JournalArticle)result;
18587                    }
18588            }
18589    
18590            /**
18591             * Removes the journal article where groupId = &#63; and classNameId = &#63; and structureId = &#63; from the database.
18592             *
18593             * @param groupId the group ID
18594             * @param classNameId the class name ID
18595             * @param structureId the structure ID
18596             * @return the journal article that was removed
18597             * @throws SystemException if a system exception occurred
18598             */
18599            public JournalArticle removeByG_C_S(long groupId, long classNameId,
18600                    String structureId) throws NoSuchArticleException, SystemException {
18601                    JournalArticle journalArticle = findByG_C_S(groupId, classNameId,
18602                                    structureId);
18603    
18604                    return remove(journalArticle);
18605            }
18606    
18607            /**
18608             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and structureId = &#63;.
18609             *
18610             * @param groupId the group ID
18611             * @param classNameId the class name ID
18612             * @param structureId the structure ID
18613             * @return the number of matching journal articles
18614             * @throws SystemException if a system exception occurred
18615             */
18616            public int countByG_C_S(long groupId, long classNameId, String structureId)
18617                    throws SystemException {
18618                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_S;
18619    
18620                    Object[] finderArgs = new Object[] { groupId, classNameId, structureId };
18621    
18622                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
18623                                    this);
18624    
18625                    if (count == null) {
18626                            StringBundler query = new StringBundler(4);
18627    
18628                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
18629    
18630                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
18631    
18632                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
18633    
18634                            boolean bindStructureId = false;
18635    
18636                            if (structureId == null) {
18637                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_1);
18638                            }
18639                            else if (structureId.equals(StringPool.BLANK)) {
18640                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_3);
18641                            }
18642                            else {
18643                                    bindStructureId = true;
18644    
18645                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_2);
18646                            }
18647    
18648                            String sql = query.toString();
18649    
18650                            Session session = null;
18651    
18652                            try {
18653                                    session = openSession();
18654    
18655                                    Query q = session.createQuery(sql);
18656    
18657                                    QueryPos qPos = QueryPos.getInstance(q);
18658    
18659                                    qPos.add(groupId);
18660    
18661                                    qPos.add(classNameId);
18662    
18663                                    if (bindStructureId) {
18664                                            qPos.add(structureId);
18665                                    }
18666    
18667                                    count = (Long)q.uniqueResult();
18668    
18669                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
18670                            }
18671                            catch (Exception e) {
18672                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18673    
18674                                    throw processException(e);
18675                            }
18676                            finally {
18677                                    closeSession(session);
18678                            }
18679                    }
18680    
18681                    return count.intValue();
18682            }
18683    
18684            private static final String _FINDER_COLUMN_G_C_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
18685            private static final String _FINDER_COLUMN_G_C_S_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
18686            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
18687            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
18688            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = '')";
18689            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18690                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
18691                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
18692                            "findByG_C_T",
18693                            new String[] {
18694                                    Long.class.getName(), Long.class.getName(),
18695                                    String.class.getName(),
18696                                    
18697                            Integer.class.getName(), Integer.class.getName(),
18698                                    OrderByComparator.class.getName()
18699                            });
18700            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18701                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
18702                            JournalArticleImpl.class,
18703                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_T",
18704                            new String[] {
18705                                    Long.class.getName(), Long.class.getName(),
18706                                    String.class.getName()
18707                            },
18708                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
18709                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
18710                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK |
18711                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
18712                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
18713            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18714                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
18715                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_T",
18716                            new String[] {
18717                                    Long.class.getName(), Long.class.getName(),
18718                                    String.class.getName()
18719                            });
18720    
18721            /**
18722             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
18723             *
18724             * @param groupId the group ID
18725             * @param classNameId the class name ID
18726             * @param templateId the template ID
18727             * @return the matching journal articles
18728             * @throws SystemException if a system exception occurred
18729             */
18730            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
18731                    String templateId) throws SystemException {
18732                    return findByG_C_T(groupId, classNameId, templateId, QueryUtil.ALL_POS,
18733                            QueryUtil.ALL_POS, null);
18734            }
18735    
18736            /**
18737             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
18738             *
18739             * <p>
18740             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18741             * </p>
18742             *
18743             * @param groupId the group ID
18744             * @param classNameId the class name ID
18745             * @param templateId the template ID
18746             * @param start the lower bound of the range of journal articles
18747             * @param end the upper bound of the range of journal articles (not inclusive)
18748             * @return the range of matching journal articles
18749             * @throws SystemException if a system exception occurred
18750             */
18751            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
18752                    String templateId, int start, int end) throws SystemException {
18753                    return findByG_C_T(groupId, classNameId, templateId, start, end, null);
18754            }
18755    
18756            /**
18757             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
18758             *
18759             * <p>
18760             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18761             * </p>
18762             *
18763             * @param groupId the group ID
18764             * @param classNameId the class name ID
18765             * @param templateId the template ID
18766             * @param start the lower bound of the range of journal articles
18767             * @param end the upper bound of the range of journal articles (not inclusive)
18768             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18769             * @return the ordered range of matching journal articles
18770             * @throws SystemException if a system exception occurred
18771             */
18772            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
18773                    String templateId, int start, int end,
18774                    OrderByComparator orderByComparator) throws SystemException {
18775                    boolean pagination = true;
18776                    FinderPath finderPath = null;
18777                    Object[] finderArgs = null;
18778    
18779                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
18780                                    (orderByComparator == null)) {
18781                            pagination = false;
18782                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T;
18783                            finderArgs = new Object[] { groupId, classNameId, templateId };
18784                    }
18785                    else {
18786                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T;
18787                            finderArgs = new Object[] {
18788                                            groupId, classNameId, templateId,
18789                                            
18790                                            start, end, orderByComparator
18791                                    };
18792                    }
18793    
18794                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
18795                                    finderArgs, this);
18796    
18797                    if ((list != null) && !list.isEmpty()) {
18798                            for (JournalArticle journalArticle : list) {
18799                                    if ((groupId != journalArticle.getGroupId()) ||
18800                                                    (classNameId != journalArticle.getClassNameId()) ||
18801                                                    !Validator.equals(templateId,
18802                                                            journalArticle.getTemplateId())) {
18803                                            list = null;
18804    
18805                                            break;
18806                                    }
18807                            }
18808                    }
18809    
18810                    if (list == null) {
18811                            StringBundler query = null;
18812    
18813                            if (orderByComparator != null) {
18814                                    query = new StringBundler(5 +
18815                                                    (orderByComparator.getOrderByFields().length * 3));
18816                            }
18817                            else {
18818                                    query = new StringBundler(5);
18819                            }
18820    
18821                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
18822    
18823                            query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
18824    
18825                            query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
18826    
18827                            boolean bindTemplateId = false;
18828    
18829                            if (templateId == null) {
18830                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
18831                            }
18832                            else if (templateId.equals(StringPool.BLANK)) {
18833                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
18834                            }
18835                            else {
18836                                    bindTemplateId = true;
18837    
18838                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
18839                            }
18840    
18841                            if (orderByComparator != null) {
18842                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18843                                            orderByComparator);
18844                            }
18845                            else
18846                             if (pagination) {
18847                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18848                            }
18849    
18850                            String sql = query.toString();
18851    
18852                            Session session = null;
18853    
18854                            try {
18855                                    session = openSession();
18856    
18857                                    Query q = session.createQuery(sql);
18858    
18859                                    QueryPos qPos = QueryPos.getInstance(q);
18860    
18861                                    qPos.add(groupId);
18862    
18863                                    qPos.add(classNameId);
18864    
18865                                    if (bindTemplateId) {
18866                                            qPos.add(templateId);
18867                                    }
18868    
18869                                    if (!pagination) {
18870                                            list = (List<JournalArticle>)QueryUtil.list(q,
18871                                                            getDialect(), start, end, false);
18872    
18873                                            Collections.sort(list);
18874    
18875                                            list = new UnmodifiableList<JournalArticle>(list);
18876                                    }
18877                                    else {
18878                                            list = (List<JournalArticle>)QueryUtil.list(q,
18879                                                            getDialect(), start, end);
18880                                    }
18881    
18882                                    cacheResult(list);
18883    
18884                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
18885                            }
18886                            catch (Exception e) {
18887                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18888    
18889                                    throw processException(e);
18890                            }
18891                            finally {
18892                                    closeSession(session);
18893                            }
18894                    }
18895    
18896                    return list;
18897            }
18898    
18899            /**
18900             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
18901             *
18902             * @param groupId the group ID
18903             * @param classNameId the class name ID
18904             * @param templateId the template ID
18905             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18906             * @return the first matching journal article
18907             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
18908             * @throws SystemException if a system exception occurred
18909             */
18910            public JournalArticle findByG_C_T_First(long groupId, long classNameId,
18911                    String templateId, OrderByComparator orderByComparator)
18912                    throws NoSuchArticleException, SystemException {
18913                    JournalArticle journalArticle = fetchByG_C_T_First(groupId,
18914                                    classNameId, templateId, orderByComparator);
18915    
18916                    if (journalArticle != null) {
18917                            return journalArticle;
18918                    }
18919    
18920                    StringBundler msg = new StringBundler(8);
18921    
18922                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
18923    
18924                    msg.append("groupId=");
18925                    msg.append(groupId);
18926    
18927                    msg.append(", classNameId=");
18928                    msg.append(classNameId);
18929    
18930                    msg.append(", templateId=");
18931                    msg.append(templateId);
18932    
18933                    msg.append(StringPool.CLOSE_CURLY_BRACE);
18934    
18935                    throw new NoSuchArticleException(msg.toString());
18936            }
18937    
18938            /**
18939             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
18940             *
18941             * @param groupId the group ID
18942             * @param classNameId the class name ID
18943             * @param templateId the template ID
18944             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18945             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
18946             * @throws SystemException if a system exception occurred
18947             */
18948            public JournalArticle fetchByG_C_T_First(long groupId, long classNameId,
18949                    String templateId, OrderByComparator orderByComparator)
18950                    throws SystemException {
18951                    List<JournalArticle> list = findByG_C_T(groupId, classNameId,
18952                                    templateId, 0, 1, orderByComparator);
18953    
18954                    if (!list.isEmpty()) {
18955                            return list.get(0);
18956                    }
18957    
18958                    return null;
18959            }
18960    
18961            /**
18962             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
18963             *
18964             * @param groupId the group ID
18965             * @param classNameId the class name ID
18966             * @param templateId the template ID
18967             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18968             * @return the last matching journal article
18969             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
18970             * @throws SystemException if a system exception occurred
18971             */
18972            public JournalArticle findByG_C_T_Last(long groupId, long classNameId,
18973                    String templateId, OrderByComparator orderByComparator)
18974                    throws NoSuchArticleException, SystemException {
18975                    JournalArticle journalArticle = fetchByG_C_T_Last(groupId, classNameId,
18976                                    templateId, orderByComparator);
18977    
18978                    if (journalArticle != null) {
18979                            return journalArticle;
18980                    }
18981    
18982                    StringBundler msg = new StringBundler(8);
18983    
18984                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
18985    
18986                    msg.append("groupId=");
18987                    msg.append(groupId);
18988    
18989                    msg.append(", classNameId=");
18990                    msg.append(classNameId);
18991    
18992                    msg.append(", templateId=");
18993                    msg.append(templateId);
18994    
18995                    msg.append(StringPool.CLOSE_CURLY_BRACE);
18996    
18997                    throw new NoSuchArticleException(msg.toString());
18998            }
18999    
19000            /**
19001             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
19002             *
19003             * @param groupId the group ID
19004             * @param classNameId the class name ID
19005             * @param templateId the template ID
19006             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19007             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
19008             * @throws SystemException if a system exception occurred
19009             */
19010            public JournalArticle fetchByG_C_T_Last(long groupId, long classNameId,
19011                    String templateId, OrderByComparator orderByComparator)
19012                    throws SystemException {
19013                    int count = countByG_C_T(groupId, classNameId, templateId);
19014    
19015                    List<JournalArticle> list = findByG_C_T(groupId, classNameId,
19016                                    templateId, count - 1, count, orderByComparator);
19017    
19018                    if (!list.isEmpty()) {
19019                            return list.get(0);
19020                    }
19021    
19022                    return null;
19023            }
19024    
19025            /**
19026             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
19027             *
19028             * @param id the primary key of the current journal article
19029             * @param groupId the group ID
19030             * @param classNameId the class name ID
19031             * @param templateId the template ID
19032             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19033             * @return the previous, current, and next journal article
19034             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
19035             * @throws SystemException if a system exception occurred
19036             */
19037            public JournalArticle[] findByG_C_T_PrevAndNext(long id, long groupId,
19038                    long classNameId, String templateId, OrderByComparator orderByComparator)
19039                    throws NoSuchArticleException, SystemException {
19040                    JournalArticle journalArticle = findByPrimaryKey(id);
19041    
19042                    Session session = null;
19043    
19044                    try {
19045                            session = openSession();
19046    
19047                            JournalArticle[] array = new JournalArticleImpl[3];
19048    
19049                            array[0] = getByG_C_T_PrevAndNext(session, journalArticle, groupId,
19050                                            classNameId, templateId, orderByComparator, true);
19051    
19052                            array[1] = journalArticle;
19053    
19054                            array[2] = getByG_C_T_PrevAndNext(session, journalArticle, groupId,
19055                                            classNameId, templateId, orderByComparator, false);
19056    
19057                            return array;
19058                    }
19059                    catch (Exception e) {
19060                            throw processException(e);
19061                    }
19062                    finally {
19063                            closeSession(session);
19064                    }
19065            }
19066    
19067            protected JournalArticle getByG_C_T_PrevAndNext(Session session,
19068                    JournalArticle journalArticle, long groupId, long classNameId,
19069                    String templateId, OrderByComparator orderByComparator, boolean previous) {
19070                    StringBundler query = null;
19071    
19072                    if (orderByComparator != null) {
19073                            query = new StringBundler(6 +
19074                                            (orderByComparator.getOrderByFields().length * 6));
19075                    }
19076                    else {
19077                            query = new StringBundler(3);
19078                    }
19079    
19080                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
19081    
19082                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
19083    
19084                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
19085    
19086                    boolean bindTemplateId = false;
19087    
19088                    if (templateId == null) {
19089                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
19090                    }
19091                    else if (templateId.equals(StringPool.BLANK)) {
19092                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
19093                    }
19094                    else {
19095                            bindTemplateId = true;
19096    
19097                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
19098                    }
19099    
19100                    if (orderByComparator != null) {
19101                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
19102    
19103                            if (orderByConditionFields.length > 0) {
19104                                    query.append(WHERE_AND);
19105                            }
19106    
19107                            for (int i = 0; i < orderByConditionFields.length; i++) {
19108                                    query.append(_ORDER_BY_ENTITY_ALIAS);
19109                                    query.append(orderByConditionFields[i]);
19110    
19111                                    if ((i + 1) < orderByConditionFields.length) {
19112                                            if (orderByComparator.isAscending() ^ previous) {
19113                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
19114                                            }
19115                                            else {
19116                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
19117                                            }
19118                                    }
19119                                    else {
19120                                            if (orderByComparator.isAscending() ^ previous) {
19121                                                    query.append(WHERE_GREATER_THAN);
19122                                            }
19123                                            else {
19124                                                    query.append(WHERE_LESSER_THAN);
19125                                            }
19126                                    }
19127                            }
19128    
19129                            query.append(ORDER_BY_CLAUSE);
19130    
19131                            String[] orderByFields = orderByComparator.getOrderByFields();
19132    
19133                            for (int i = 0; i < orderByFields.length; i++) {
19134                                    query.append(_ORDER_BY_ENTITY_ALIAS);
19135                                    query.append(orderByFields[i]);
19136    
19137                                    if ((i + 1) < orderByFields.length) {
19138                                            if (orderByComparator.isAscending() ^ previous) {
19139                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
19140                                            }
19141                                            else {
19142                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
19143                                            }
19144                                    }
19145                                    else {
19146                                            if (orderByComparator.isAscending() ^ previous) {
19147                                                    query.append(ORDER_BY_ASC);
19148                                            }
19149                                            else {
19150                                                    query.append(ORDER_BY_DESC);
19151                                            }
19152                                    }
19153                            }
19154                    }
19155                    else {
19156                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19157                    }
19158    
19159                    String sql = query.toString();
19160    
19161                    Query q = session.createQuery(sql);
19162    
19163                    q.setFirstResult(0);
19164                    q.setMaxResults(2);
19165    
19166                    QueryPos qPos = QueryPos.getInstance(q);
19167    
19168                    qPos.add(groupId);
19169    
19170                    qPos.add(classNameId);
19171    
19172                    if (bindTemplateId) {
19173                            qPos.add(templateId);
19174                    }
19175    
19176                    if (orderByComparator != null) {
19177                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
19178    
19179                            for (Object value : values) {
19180                                    qPos.add(value);
19181                            }
19182                    }
19183    
19184                    List<JournalArticle> list = q.list();
19185    
19186                    if (list.size() == 2) {
19187                            return list.get(1);
19188                    }
19189                    else {
19190                            return null;
19191                    }
19192            }
19193    
19194            /**
19195             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
19196             *
19197             * @param groupId the group ID
19198             * @param classNameId the class name ID
19199             * @param templateId the template ID
19200             * @return the matching journal articles that the user has permission to view
19201             * @throws SystemException if a system exception occurred
19202             */
19203            public List<JournalArticle> filterFindByG_C_T(long groupId,
19204                    long classNameId, String templateId) throws SystemException {
19205                    return filterFindByG_C_T(groupId, classNameId, templateId,
19206                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
19207            }
19208    
19209            /**
19210             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
19211             *
19212             * <p>
19213             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19214             * </p>
19215             *
19216             * @param groupId the group ID
19217             * @param classNameId the class name ID
19218             * @param templateId the template ID
19219             * @param start the lower bound of the range of journal articles
19220             * @param end the upper bound of the range of journal articles (not inclusive)
19221             * @return the range of matching journal articles that the user has permission to view
19222             * @throws SystemException if a system exception occurred
19223             */
19224            public List<JournalArticle> filterFindByG_C_T(long groupId,
19225                    long classNameId, String templateId, int start, int end)
19226                    throws SystemException {
19227                    return filterFindByG_C_T(groupId, classNameId, templateId, start, end,
19228                            null);
19229            }
19230    
19231            /**
19232             * 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;.
19233             *
19234             * <p>
19235             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19236             * </p>
19237             *
19238             * @param groupId the group ID
19239             * @param classNameId the class name ID
19240             * @param templateId the template ID
19241             * @param start the lower bound of the range of journal articles
19242             * @param end the upper bound of the range of journal articles (not inclusive)
19243             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19244             * @return the ordered range of matching journal articles that the user has permission to view
19245             * @throws SystemException if a system exception occurred
19246             */
19247            public List<JournalArticle> filterFindByG_C_T(long groupId,
19248                    long classNameId, String templateId, int start, int end,
19249                    OrderByComparator orderByComparator) throws SystemException {
19250                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19251                            return findByG_C_T(groupId, classNameId, templateId, start, end,
19252                                    orderByComparator);
19253                    }
19254    
19255                    StringBundler query = null;
19256    
19257                    if (orderByComparator != null) {
19258                            query = new StringBundler(5 +
19259                                            (orderByComparator.getOrderByFields().length * 3));
19260                    }
19261                    else {
19262                            query = new StringBundler(5);
19263                    }
19264    
19265                    if (getDB().isSupportsInlineDistinct()) {
19266                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
19267                    }
19268                    else {
19269                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
19270                    }
19271    
19272                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
19273    
19274                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
19275    
19276                    boolean bindTemplateId = false;
19277    
19278                    if (templateId == null) {
19279                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
19280                    }
19281                    else if (templateId.equals(StringPool.BLANK)) {
19282                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
19283                    }
19284                    else {
19285                            bindTemplateId = true;
19286    
19287                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
19288                    }
19289    
19290                    if (!getDB().isSupportsInlineDistinct()) {
19291                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
19292                    }
19293    
19294                    if (orderByComparator != null) {
19295                            if (getDB().isSupportsInlineDistinct()) {
19296                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
19297                                            orderByComparator);
19298                            }
19299                            else {
19300                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
19301                                            orderByComparator);
19302                            }
19303                    }
19304                    else {
19305                            if (getDB().isSupportsInlineDistinct()) {
19306                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19307                            }
19308                            else {
19309                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
19310                            }
19311                    }
19312    
19313                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19314                                    JournalArticle.class.getName(),
19315                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19316    
19317                    Session session = null;
19318    
19319                    try {
19320                            session = openSession();
19321    
19322                            SQLQuery q = session.createSQLQuery(sql);
19323    
19324                            if (getDB().isSupportsInlineDistinct()) {
19325                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
19326                            }
19327                            else {
19328                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
19329                            }
19330    
19331                            QueryPos qPos = QueryPos.getInstance(q);
19332    
19333                            qPos.add(groupId);
19334    
19335                            qPos.add(classNameId);
19336    
19337                            if (bindTemplateId) {
19338                                    qPos.add(templateId);
19339                            }
19340    
19341                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
19342                                    end);
19343                    }
19344                    catch (Exception e) {
19345                            throw processException(e);
19346                    }
19347                    finally {
19348                            closeSession(session);
19349                    }
19350            }
19351    
19352            /**
19353             * 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;.
19354             *
19355             * @param id the primary key of the current journal article
19356             * @param groupId the group ID
19357             * @param classNameId the class name ID
19358             * @param templateId the template ID
19359             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19360             * @return the previous, current, and next journal article
19361             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
19362             * @throws SystemException if a system exception occurred
19363             */
19364            public JournalArticle[] filterFindByG_C_T_PrevAndNext(long id,
19365                    long groupId, long classNameId, String templateId,
19366                    OrderByComparator orderByComparator)
19367                    throws NoSuchArticleException, SystemException {
19368                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19369                            return findByG_C_T_PrevAndNext(id, groupId, classNameId,
19370                                    templateId, orderByComparator);
19371                    }
19372    
19373                    JournalArticle journalArticle = findByPrimaryKey(id);
19374    
19375                    Session session = null;
19376    
19377                    try {
19378                            session = openSession();
19379    
19380                            JournalArticle[] array = new JournalArticleImpl[3];
19381    
19382                            array[0] = filterGetByG_C_T_PrevAndNext(session, journalArticle,
19383                                            groupId, classNameId, templateId, orderByComparator, true);
19384    
19385                            array[1] = journalArticle;
19386    
19387                            array[2] = filterGetByG_C_T_PrevAndNext(session, journalArticle,
19388                                            groupId, classNameId, templateId, orderByComparator, false);
19389    
19390                            return array;
19391                    }
19392                    catch (Exception e) {
19393                            throw processException(e);
19394                    }
19395                    finally {
19396                            closeSession(session);
19397                    }
19398            }
19399    
19400            protected JournalArticle filterGetByG_C_T_PrevAndNext(Session session,
19401                    JournalArticle journalArticle, long groupId, long classNameId,
19402                    String templateId, OrderByComparator orderByComparator, boolean previous) {
19403                    StringBundler query = null;
19404    
19405                    if (orderByComparator != null) {
19406                            query = new StringBundler(6 +
19407                                            (orderByComparator.getOrderByFields().length * 6));
19408                    }
19409                    else {
19410                            query = new StringBundler(3);
19411                    }
19412    
19413                    if (getDB().isSupportsInlineDistinct()) {
19414                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
19415                    }
19416                    else {
19417                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
19418                    }
19419    
19420                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
19421    
19422                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
19423    
19424                    boolean bindTemplateId = false;
19425    
19426                    if (templateId == null) {
19427                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
19428                    }
19429                    else if (templateId.equals(StringPool.BLANK)) {
19430                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
19431                    }
19432                    else {
19433                            bindTemplateId = true;
19434    
19435                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
19436                    }
19437    
19438                    if (!getDB().isSupportsInlineDistinct()) {
19439                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
19440                    }
19441    
19442                    if (orderByComparator != null) {
19443                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
19444    
19445                            if (orderByConditionFields.length > 0) {
19446                                    query.append(WHERE_AND);
19447                            }
19448    
19449                            for (int i = 0; i < orderByConditionFields.length; i++) {
19450                                    if (getDB().isSupportsInlineDistinct()) {
19451                                            query.append(_ORDER_BY_ENTITY_ALIAS);
19452                                    }
19453                                    else {
19454                                            query.append(_ORDER_BY_ENTITY_TABLE);
19455                                    }
19456    
19457                                    query.append(orderByConditionFields[i]);
19458    
19459                                    if ((i + 1) < orderByConditionFields.length) {
19460                                            if (orderByComparator.isAscending() ^ previous) {
19461                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
19462                                            }
19463                                            else {
19464                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
19465                                            }
19466                                    }
19467                                    else {
19468                                            if (orderByComparator.isAscending() ^ previous) {
19469                                                    query.append(WHERE_GREATER_THAN);
19470                                            }
19471                                            else {
19472                                                    query.append(WHERE_LESSER_THAN);
19473                                            }
19474                                    }
19475                            }
19476    
19477                            query.append(ORDER_BY_CLAUSE);
19478    
19479                            String[] orderByFields = orderByComparator.getOrderByFields();
19480    
19481                            for (int i = 0; i < orderByFields.length; i++) {
19482                                    if (getDB().isSupportsInlineDistinct()) {
19483                                            query.append(_ORDER_BY_ENTITY_ALIAS);
19484                                    }
19485                                    else {
19486                                            query.append(_ORDER_BY_ENTITY_TABLE);
19487                                    }
19488    
19489                                    query.append(orderByFields[i]);
19490    
19491                                    if ((i + 1) < orderByFields.length) {
19492                                            if (orderByComparator.isAscending() ^ previous) {
19493                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
19494                                            }
19495                                            else {
19496                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
19497                                            }
19498                                    }
19499                                    else {
19500                                            if (orderByComparator.isAscending() ^ previous) {
19501                                                    query.append(ORDER_BY_ASC);
19502                                            }
19503                                            else {
19504                                                    query.append(ORDER_BY_DESC);
19505                                            }
19506                                    }
19507                            }
19508                    }
19509                    else {
19510                            if (getDB().isSupportsInlineDistinct()) {
19511                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19512                            }
19513                            else {
19514                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
19515                            }
19516                    }
19517    
19518                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19519                                    JournalArticle.class.getName(),
19520                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19521    
19522                    SQLQuery q = session.createSQLQuery(sql);
19523    
19524                    q.setFirstResult(0);
19525                    q.setMaxResults(2);
19526    
19527                    if (getDB().isSupportsInlineDistinct()) {
19528                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
19529                    }
19530                    else {
19531                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
19532                    }
19533    
19534                    QueryPos qPos = QueryPos.getInstance(q);
19535    
19536                    qPos.add(groupId);
19537    
19538                    qPos.add(classNameId);
19539    
19540                    if (bindTemplateId) {
19541                            qPos.add(templateId);
19542                    }
19543    
19544                    if (orderByComparator != null) {
19545                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
19546    
19547                            for (Object value : values) {
19548                                    qPos.add(value);
19549                            }
19550                    }
19551    
19552                    List<JournalArticle> list = q.list();
19553    
19554                    if (list.size() == 2) {
19555                            return list.get(1);
19556                    }
19557                    else {
19558                            return null;
19559                    }
19560            }
19561    
19562            /**
19563             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63; from the database.
19564             *
19565             * @param groupId the group ID
19566             * @param classNameId the class name ID
19567             * @param templateId the template ID
19568             * @throws SystemException if a system exception occurred
19569             */
19570            public void removeByG_C_T(long groupId, long classNameId, String templateId)
19571                    throws SystemException {
19572                    for (JournalArticle journalArticle : findByG_C_T(groupId, classNameId,
19573                                    templateId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
19574                            remove(journalArticle);
19575                    }
19576            }
19577    
19578            /**
19579             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
19580             *
19581             * @param groupId the group ID
19582             * @param classNameId the class name ID
19583             * @param templateId the template ID
19584             * @return the number of matching journal articles
19585             * @throws SystemException if a system exception occurred
19586             */
19587            public int countByG_C_T(long groupId, long classNameId, String templateId)
19588                    throws SystemException {
19589                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_T;
19590    
19591                    Object[] finderArgs = new Object[] { groupId, classNameId, templateId };
19592    
19593                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
19594                                    this);
19595    
19596                    if (count == null) {
19597                            StringBundler query = new StringBundler(4);
19598    
19599                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
19600    
19601                            query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
19602    
19603                            query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
19604    
19605                            boolean bindTemplateId = false;
19606    
19607                            if (templateId == null) {
19608                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
19609                            }
19610                            else if (templateId.equals(StringPool.BLANK)) {
19611                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
19612                            }
19613                            else {
19614                                    bindTemplateId = true;
19615    
19616                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
19617                            }
19618    
19619                            String sql = query.toString();
19620    
19621                            Session session = null;
19622    
19623                            try {
19624                                    session = openSession();
19625    
19626                                    Query q = session.createQuery(sql);
19627    
19628                                    QueryPos qPos = QueryPos.getInstance(q);
19629    
19630                                    qPos.add(groupId);
19631    
19632                                    qPos.add(classNameId);
19633    
19634                                    if (bindTemplateId) {
19635                                            qPos.add(templateId);
19636                                    }
19637    
19638                                    count = (Long)q.uniqueResult();
19639    
19640                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
19641                            }
19642                            catch (Exception e) {
19643                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
19644    
19645                                    throw processException(e);
19646                            }
19647                            finally {
19648                                    closeSession(session);
19649                            }
19650                    }
19651    
19652                    return count.intValue();
19653            }
19654    
19655            /**
19656             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
19657             *
19658             * @param groupId the group ID
19659             * @param classNameId the class name ID
19660             * @param templateId the template ID
19661             * @return the number of matching journal articles that the user has permission to view
19662             * @throws SystemException if a system exception occurred
19663             */
19664            public int filterCountByG_C_T(long groupId, long classNameId,
19665                    String templateId) throws SystemException {
19666                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19667                            return countByG_C_T(groupId, classNameId, templateId);
19668                    }
19669    
19670                    StringBundler query = new StringBundler(4);
19671    
19672                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
19673    
19674                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
19675    
19676                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
19677    
19678                    boolean bindTemplateId = false;
19679    
19680                    if (templateId == null) {
19681                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
19682                    }
19683                    else if (templateId.equals(StringPool.BLANK)) {
19684                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
19685                    }
19686                    else {
19687                            bindTemplateId = true;
19688    
19689                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
19690                    }
19691    
19692                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19693                                    JournalArticle.class.getName(),
19694                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19695    
19696                    Session session = null;
19697    
19698                    try {
19699                            session = openSession();
19700    
19701                            SQLQuery q = session.createSQLQuery(sql);
19702    
19703                            q.addScalar(COUNT_COLUMN_NAME,
19704                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
19705    
19706                            QueryPos qPos = QueryPos.getInstance(q);
19707    
19708                            qPos.add(groupId);
19709    
19710                            qPos.add(classNameId);
19711    
19712                            if (bindTemplateId) {
19713                                    qPos.add(templateId);
19714                            }
19715    
19716                            Long count = (Long)q.uniqueResult();
19717    
19718                            return count.intValue();
19719                    }
19720                    catch (Exception e) {
19721                            throw processException(e);
19722                    }
19723                    finally {
19724                            closeSession(session);
19725                    }
19726            }
19727    
19728            private static final String _FINDER_COLUMN_G_C_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
19729            private static final String _FINDER_COLUMN_G_C_T_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
19730            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
19731            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
19732            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = '')";
19733            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19734                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
19735                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
19736                            "findByG_C_L",
19737                            new String[] {
19738                                    Long.class.getName(), Long.class.getName(),
19739                                    String.class.getName(),
19740                                    
19741                            Integer.class.getName(), Integer.class.getName(),
19742                                    OrderByComparator.class.getName()
19743                            });
19744            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19745                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
19746                            JournalArticleImpl.class,
19747                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_L",
19748                            new String[] {
19749                                    Long.class.getName(), Long.class.getName(),
19750                                    String.class.getName()
19751                            },
19752                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
19753                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
19754                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK |
19755                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
19756                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
19757            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19758                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
19759                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_L",
19760                            new String[] {
19761                                    Long.class.getName(), Long.class.getName(),
19762                                    String.class.getName()
19763                            });
19764    
19765            /**
19766             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
19767             *
19768             * @param groupId the group ID
19769             * @param classNameId the class name ID
19770             * @param layoutUuid the layout uuid
19771             * @return the matching journal articles
19772             * @throws SystemException if a system exception occurred
19773             */
19774            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
19775                    String layoutUuid) throws SystemException {
19776                    return findByG_C_L(groupId, classNameId, layoutUuid, QueryUtil.ALL_POS,
19777                            QueryUtil.ALL_POS, null);
19778            }
19779    
19780            /**
19781             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
19782             *
19783             * <p>
19784             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19785             * </p>
19786             *
19787             * @param groupId the group ID
19788             * @param classNameId the class name ID
19789             * @param layoutUuid the layout uuid
19790             * @param start the lower bound of the range of journal articles
19791             * @param end the upper bound of the range of journal articles (not inclusive)
19792             * @return the range of matching journal articles
19793             * @throws SystemException if a system exception occurred
19794             */
19795            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
19796                    String layoutUuid, int start, int end) throws SystemException {
19797                    return findByG_C_L(groupId, classNameId, layoutUuid, start, end, null);
19798            }
19799    
19800            /**
19801             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
19802             *
19803             * <p>
19804             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19805             * </p>
19806             *
19807             * @param groupId the group ID
19808             * @param classNameId the class name ID
19809             * @param layoutUuid the layout uuid
19810             * @param start the lower bound of the range of journal articles
19811             * @param end the upper bound of the range of journal articles (not inclusive)
19812             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19813             * @return the ordered range of matching journal articles
19814             * @throws SystemException if a system exception occurred
19815             */
19816            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
19817                    String layoutUuid, int start, int end,
19818                    OrderByComparator orderByComparator) throws SystemException {
19819                    boolean pagination = true;
19820                    FinderPath finderPath = null;
19821                    Object[] finderArgs = null;
19822    
19823                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
19824                                    (orderByComparator == null)) {
19825                            pagination = false;
19826                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L;
19827                            finderArgs = new Object[] { groupId, classNameId, layoutUuid };
19828                    }
19829                    else {
19830                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L;
19831                            finderArgs = new Object[] {
19832                                            groupId, classNameId, layoutUuid,
19833                                            
19834                                            start, end, orderByComparator
19835                                    };
19836                    }
19837    
19838                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
19839                                    finderArgs, this);
19840    
19841                    if ((list != null) && !list.isEmpty()) {
19842                            for (JournalArticle journalArticle : list) {
19843                                    if ((groupId != journalArticle.getGroupId()) ||
19844                                                    (classNameId != journalArticle.getClassNameId()) ||
19845                                                    !Validator.equals(layoutUuid,
19846                                                            journalArticle.getLayoutUuid())) {
19847                                            list = null;
19848    
19849                                            break;
19850                                    }
19851                            }
19852                    }
19853    
19854                    if (list == null) {
19855                            StringBundler query = null;
19856    
19857                            if (orderByComparator != null) {
19858                                    query = new StringBundler(5 +
19859                                                    (orderByComparator.getOrderByFields().length * 3));
19860                            }
19861                            else {
19862                                    query = new StringBundler(5);
19863                            }
19864    
19865                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
19866    
19867                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
19868    
19869                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
19870    
19871                            boolean bindLayoutUuid = false;
19872    
19873                            if (layoutUuid == null) {
19874                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
19875                            }
19876                            else if (layoutUuid.equals(StringPool.BLANK)) {
19877                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
19878                            }
19879                            else {
19880                                    bindLayoutUuid = true;
19881    
19882                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
19883                            }
19884    
19885                            if (orderByComparator != null) {
19886                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
19887                                            orderByComparator);
19888                            }
19889                            else
19890                             if (pagination) {
19891                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19892                            }
19893    
19894                            String sql = query.toString();
19895    
19896                            Session session = null;
19897    
19898                            try {
19899                                    session = openSession();
19900    
19901                                    Query q = session.createQuery(sql);
19902    
19903                                    QueryPos qPos = QueryPos.getInstance(q);
19904    
19905                                    qPos.add(groupId);
19906    
19907                                    qPos.add(classNameId);
19908    
19909                                    if (bindLayoutUuid) {
19910                                            qPos.add(layoutUuid);
19911                                    }
19912    
19913                                    if (!pagination) {
19914                                            list = (List<JournalArticle>)QueryUtil.list(q,
19915                                                            getDialect(), start, end, false);
19916    
19917                                            Collections.sort(list);
19918    
19919                                            list = new UnmodifiableList<JournalArticle>(list);
19920                                    }
19921                                    else {
19922                                            list = (List<JournalArticle>)QueryUtil.list(q,
19923                                                            getDialect(), start, end);
19924                                    }
19925    
19926                                    cacheResult(list);
19927    
19928                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
19929                            }
19930                            catch (Exception e) {
19931                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
19932    
19933                                    throw processException(e);
19934                            }
19935                            finally {
19936                                    closeSession(session);
19937                            }
19938                    }
19939    
19940                    return list;
19941            }
19942    
19943            /**
19944             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
19945             *
19946             * @param groupId the group ID
19947             * @param classNameId the class name ID
19948             * @param layoutUuid the layout uuid
19949             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19950             * @return the first matching journal article
19951             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
19952             * @throws SystemException if a system exception occurred
19953             */
19954            public JournalArticle findByG_C_L_First(long groupId, long classNameId,
19955                    String layoutUuid, OrderByComparator orderByComparator)
19956                    throws NoSuchArticleException, SystemException {
19957                    JournalArticle journalArticle = fetchByG_C_L_First(groupId,
19958                                    classNameId, layoutUuid, orderByComparator);
19959    
19960                    if (journalArticle != null) {
19961                            return journalArticle;
19962                    }
19963    
19964                    StringBundler msg = new StringBundler(8);
19965    
19966                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
19967    
19968                    msg.append("groupId=");
19969                    msg.append(groupId);
19970    
19971                    msg.append(", classNameId=");
19972                    msg.append(classNameId);
19973    
19974                    msg.append(", layoutUuid=");
19975                    msg.append(layoutUuid);
19976    
19977                    msg.append(StringPool.CLOSE_CURLY_BRACE);
19978    
19979                    throw new NoSuchArticleException(msg.toString());
19980            }
19981    
19982            /**
19983             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
19984             *
19985             * @param groupId the group ID
19986             * @param classNameId the class name ID
19987             * @param layoutUuid the layout uuid
19988             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19989             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
19990             * @throws SystemException if a system exception occurred
19991             */
19992            public JournalArticle fetchByG_C_L_First(long groupId, long classNameId,
19993                    String layoutUuid, OrderByComparator orderByComparator)
19994                    throws SystemException {
19995                    List<JournalArticle> list = findByG_C_L(groupId, classNameId,
19996                                    layoutUuid, 0, 1, orderByComparator);
19997    
19998                    if (!list.isEmpty()) {
19999                            return list.get(0);
20000                    }
20001    
20002                    return null;
20003            }
20004    
20005            /**
20006             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
20007             *
20008             * @param groupId the group ID
20009             * @param classNameId the class name ID
20010             * @param layoutUuid the layout uuid
20011             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20012             * @return the last matching journal article
20013             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
20014             * @throws SystemException if a system exception occurred
20015             */
20016            public JournalArticle findByG_C_L_Last(long groupId, long classNameId,
20017                    String layoutUuid, OrderByComparator orderByComparator)
20018                    throws NoSuchArticleException, SystemException {
20019                    JournalArticle journalArticle = fetchByG_C_L_Last(groupId, classNameId,
20020                                    layoutUuid, orderByComparator);
20021    
20022                    if (journalArticle != null) {
20023                            return journalArticle;
20024                    }
20025    
20026                    StringBundler msg = new StringBundler(8);
20027    
20028                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
20029    
20030                    msg.append("groupId=");
20031                    msg.append(groupId);
20032    
20033                    msg.append(", classNameId=");
20034                    msg.append(classNameId);
20035    
20036                    msg.append(", layoutUuid=");
20037                    msg.append(layoutUuid);
20038    
20039                    msg.append(StringPool.CLOSE_CURLY_BRACE);
20040    
20041                    throw new NoSuchArticleException(msg.toString());
20042            }
20043    
20044            /**
20045             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
20046             *
20047             * @param groupId the group ID
20048             * @param classNameId the class name ID
20049             * @param layoutUuid the layout uuid
20050             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20051             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
20052             * @throws SystemException if a system exception occurred
20053             */
20054            public JournalArticle fetchByG_C_L_Last(long groupId, long classNameId,
20055                    String layoutUuid, OrderByComparator orderByComparator)
20056                    throws SystemException {
20057                    int count = countByG_C_L(groupId, classNameId, layoutUuid);
20058    
20059                    List<JournalArticle> list = findByG_C_L(groupId, classNameId,
20060                                    layoutUuid, count - 1, count, orderByComparator);
20061    
20062                    if (!list.isEmpty()) {
20063                            return list.get(0);
20064                    }
20065    
20066                    return null;
20067            }
20068    
20069            /**
20070             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
20071             *
20072             * @param id the primary key of the current journal article
20073             * @param groupId the group ID
20074             * @param classNameId the class name ID
20075             * @param layoutUuid the layout uuid
20076             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20077             * @return the previous, current, and next journal article
20078             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
20079             * @throws SystemException if a system exception occurred
20080             */
20081            public JournalArticle[] findByG_C_L_PrevAndNext(long id, long groupId,
20082                    long classNameId, String layoutUuid, OrderByComparator orderByComparator)
20083                    throws NoSuchArticleException, SystemException {
20084                    JournalArticle journalArticle = findByPrimaryKey(id);
20085    
20086                    Session session = null;
20087    
20088                    try {
20089                            session = openSession();
20090    
20091                            JournalArticle[] array = new JournalArticleImpl[3];
20092    
20093                            array[0] = getByG_C_L_PrevAndNext(session, journalArticle, groupId,
20094                                            classNameId, layoutUuid, orderByComparator, true);
20095    
20096                            array[1] = journalArticle;
20097    
20098                            array[2] = getByG_C_L_PrevAndNext(session, journalArticle, groupId,
20099                                            classNameId, layoutUuid, orderByComparator, false);
20100    
20101                            return array;
20102                    }
20103                    catch (Exception e) {
20104                            throw processException(e);
20105                    }
20106                    finally {
20107                            closeSession(session);
20108                    }
20109            }
20110    
20111            protected JournalArticle getByG_C_L_PrevAndNext(Session session,
20112                    JournalArticle journalArticle, long groupId, long classNameId,
20113                    String layoutUuid, OrderByComparator orderByComparator, boolean previous) {
20114                    StringBundler query = null;
20115    
20116                    if (orderByComparator != null) {
20117                            query = new StringBundler(6 +
20118                                            (orderByComparator.getOrderByFields().length * 6));
20119                    }
20120                    else {
20121                            query = new StringBundler(3);
20122                    }
20123    
20124                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
20125    
20126                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
20127    
20128                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
20129    
20130                    boolean bindLayoutUuid = false;
20131    
20132                    if (layoutUuid == null) {
20133                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
20134                    }
20135                    else if (layoutUuid.equals(StringPool.BLANK)) {
20136                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
20137                    }
20138                    else {
20139                            bindLayoutUuid = true;
20140    
20141                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
20142                    }
20143    
20144                    if (orderByComparator != null) {
20145                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
20146    
20147                            if (orderByConditionFields.length > 0) {
20148                                    query.append(WHERE_AND);
20149                            }
20150    
20151                            for (int i = 0; i < orderByConditionFields.length; i++) {
20152                                    query.append(_ORDER_BY_ENTITY_ALIAS);
20153                                    query.append(orderByConditionFields[i]);
20154    
20155                                    if ((i + 1) < orderByConditionFields.length) {
20156                                            if (orderByComparator.isAscending() ^ previous) {
20157                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
20158                                            }
20159                                            else {
20160                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
20161                                            }
20162                                    }
20163                                    else {
20164                                            if (orderByComparator.isAscending() ^ previous) {
20165                                                    query.append(WHERE_GREATER_THAN);
20166                                            }
20167                                            else {
20168                                                    query.append(WHERE_LESSER_THAN);
20169                                            }
20170                                    }
20171                            }
20172    
20173                            query.append(ORDER_BY_CLAUSE);
20174    
20175                            String[] orderByFields = orderByComparator.getOrderByFields();
20176    
20177                            for (int i = 0; i < orderByFields.length; i++) {
20178                                    query.append(_ORDER_BY_ENTITY_ALIAS);
20179                                    query.append(orderByFields[i]);
20180    
20181                                    if ((i + 1) < orderByFields.length) {
20182                                            if (orderByComparator.isAscending() ^ previous) {
20183                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
20184                                            }
20185                                            else {
20186                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
20187                                            }
20188                                    }
20189                                    else {
20190                                            if (orderByComparator.isAscending() ^ previous) {
20191                                                    query.append(ORDER_BY_ASC);
20192                                            }
20193                                            else {
20194                                                    query.append(ORDER_BY_DESC);
20195                                            }
20196                                    }
20197                            }
20198                    }
20199                    else {
20200                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20201                    }
20202    
20203                    String sql = query.toString();
20204    
20205                    Query q = session.createQuery(sql);
20206    
20207                    q.setFirstResult(0);
20208                    q.setMaxResults(2);
20209    
20210                    QueryPos qPos = QueryPos.getInstance(q);
20211    
20212                    qPos.add(groupId);
20213    
20214                    qPos.add(classNameId);
20215    
20216                    if (bindLayoutUuid) {
20217                            qPos.add(layoutUuid);
20218                    }
20219    
20220                    if (orderByComparator != null) {
20221                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
20222    
20223                            for (Object value : values) {
20224                                    qPos.add(value);
20225                            }
20226                    }
20227    
20228                    List<JournalArticle> list = q.list();
20229    
20230                    if (list.size() == 2) {
20231                            return list.get(1);
20232                    }
20233                    else {
20234                            return null;
20235                    }
20236            }
20237    
20238            /**
20239             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
20240             *
20241             * @param groupId the group ID
20242             * @param classNameId the class name ID
20243             * @param layoutUuid the layout uuid
20244             * @return the matching journal articles that the user has permission to view
20245             * @throws SystemException if a system exception occurred
20246             */
20247            public List<JournalArticle> filterFindByG_C_L(long groupId,
20248                    long classNameId, String layoutUuid) throws SystemException {
20249                    return filterFindByG_C_L(groupId, classNameId, layoutUuid,
20250                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
20251            }
20252    
20253            /**
20254             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
20255             *
20256             * <p>
20257             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20258             * </p>
20259             *
20260             * @param groupId the group ID
20261             * @param classNameId the class name ID
20262             * @param layoutUuid the layout uuid
20263             * @param start the lower bound of the range of journal articles
20264             * @param end the upper bound of the range of journal articles (not inclusive)
20265             * @return the range of matching journal articles that the user has permission to view
20266             * @throws SystemException if a system exception occurred
20267             */
20268            public List<JournalArticle> filterFindByG_C_L(long groupId,
20269                    long classNameId, String layoutUuid, int start, int end)
20270                    throws SystemException {
20271                    return filterFindByG_C_L(groupId, classNameId, layoutUuid, start, end,
20272                            null);
20273            }
20274    
20275            /**
20276             * 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;.
20277             *
20278             * <p>
20279             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20280             * </p>
20281             *
20282             * @param groupId the group ID
20283             * @param classNameId the class name ID
20284             * @param layoutUuid the layout uuid
20285             * @param start the lower bound of the range of journal articles
20286             * @param end the upper bound of the range of journal articles (not inclusive)
20287             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
20288             * @return the ordered range of matching journal articles that the user has permission to view
20289             * @throws SystemException if a system exception occurred
20290             */
20291            public List<JournalArticle> filterFindByG_C_L(long groupId,
20292                    long classNameId, String layoutUuid, int start, int end,
20293                    OrderByComparator orderByComparator) throws SystemException {
20294                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20295                            return findByG_C_L(groupId, classNameId, layoutUuid, start, end,
20296                                    orderByComparator);
20297                    }
20298    
20299                    StringBundler query = null;
20300    
20301                    if (orderByComparator != null) {
20302                            query = new StringBundler(5 +
20303                                            (orderByComparator.getOrderByFields().length * 3));
20304                    }
20305                    else {
20306                            query = new StringBundler(5);
20307                    }
20308    
20309                    if (getDB().isSupportsInlineDistinct()) {
20310                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
20311                    }
20312                    else {
20313                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
20314                    }
20315    
20316                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
20317    
20318                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
20319    
20320                    boolean bindLayoutUuid = false;
20321    
20322                    if (layoutUuid == null) {
20323                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
20324                    }
20325                    else if (layoutUuid.equals(StringPool.BLANK)) {
20326                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
20327                    }
20328                    else {
20329                            bindLayoutUuid = true;
20330    
20331                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
20332                    }
20333    
20334                    if (!getDB().isSupportsInlineDistinct()) {
20335                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
20336                    }
20337    
20338                    if (orderByComparator != null) {
20339                            if (getDB().isSupportsInlineDistinct()) {
20340                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
20341                                            orderByComparator);
20342                            }
20343                            else {
20344                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
20345                                            orderByComparator);
20346                            }
20347                    }
20348                    else {
20349                            if (getDB().isSupportsInlineDistinct()) {
20350                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20351                            }
20352                            else {
20353                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
20354                            }
20355                    }
20356    
20357                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20358                                    JournalArticle.class.getName(),
20359                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20360    
20361                    Session session = null;
20362    
20363                    try {
20364                            session = openSession();
20365    
20366                            SQLQuery q = session.createSQLQuery(sql);
20367    
20368                            if (getDB().isSupportsInlineDistinct()) {
20369                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
20370                            }
20371                            else {
20372                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
20373                            }
20374    
20375                            QueryPos qPos = QueryPos.getInstance(q);
20376    
20377                            qPos.add(groupId);
20378    
20379                            qPos.add(classNameId);
20380    
20381                            if (bindLayoutUuid) {
20382                                    qPos.add(layoutUuid);
20383                            }
20384    
20385                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
20386                                    end);
20387                    }
20388                    catch (Exception e) {
20389                            throw processException(e);
20390                    }
20391                    finally {
20392                            closeSession(session);
20393                    }
20394            }
20395    
20396            /**
20397             * 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;.
20398             *
20399             * @param id the primary key of the current journal article
20400             * @param groupId the group ID
20401             * @param classNameId the class name ID
20402             * @param layoutUuid the layout uuid
20403             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20404             * @return the previous, current, and next journal article
20405             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
20406             * @throws SystemException if a system exception occurred
20407             */
20408            public JournalArticle[] filterFindByG_C_L_PrevAndNext(long id,
20409                    long groupId, long classNameId, String layoutUuid,
20410                    OrderByComparator orderByComparator)
20411                    throws NoSuchArticleException, SystemException {
20412                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20413                            return findByG_C_L_PrevAndNext(id, groupId, classNameId,
20414                                    layoutUuid, orderByComparator);
20415                    }
20416    
20417                    JournalArticle journalArticle = findByPrimaryKey(id);
20418    
20419                    Session session = null;
20420    
20421                    try {
20422                            session = openSession();
20423    
20424                            JournalArticle[] array = new JournalArticleImpl[3];
20425    
20426                            array[0] = filterGetByG_C_L_PrevAndNext(session, journalArticle,
20427                                            groupId, classNameId, layoutUuid, orderByComparator, true);
20428    
20429                            array[1] = journalArticle;
20430    
20431                            array[2] = filterGetByG_C_L_PrevAndNext(session, journalArticle,
20432                                            groupId, classNameId, layoutUuid, orderByComparator, false);
20433    
20434                            return array;
20435                    }
20436                    catch (Exception e) {
20437                            throw processException(e);
20438                    }
20439                    finally {
20440                            closeSession(session);
20441                    }
20442            }
20443    
20444            protected JournalArticle filterGetByG_C_L_PrevAndNext(Session session,
20445                    JournalArticle journalArticle, long groupId, long classNameId,
20446                    String layoutUuid, OrderByComparator orderByComparator, boolean previous) {
20447                    StringBundler query = null;
20448    
20449                    if (orderByComparator != null) {
20450                            query = new StringBundler(6 +
20451                                            (orderByComparator.getOrderByFields().length * 6));
20452                    }
20453                    else {
20454                            query = new StringBundler(3);
20455                    }
20456    
20457                    if (getDB().isSupportsInlineDistinct()) {
20458                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
20459                    }
20460                    else {
20461                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
20462                    }
20463    
20464                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
20465    
20466                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
20467    
20468                    boolean bindLayoutUuid = false;
20469    
20470                    if (layoutUuid == null) {
20471                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
20472                    }
20473                    else if (layoutUuid.equals(StringPool.BLANK)) {
20474                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
20475                    }
20476                    else {
20477                            bindLayoutUuid = true;
20478    
20479                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
20480                    }
20481    
20482                    if (!getDB().isSupportsInlineDistinct()) {
20483                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
20484                    }
20485    
20486                    if (orderByComparator != null) {
20487                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
20488    
20489                            if (orderByConditionFields.length > 0) {
20490                                    query.append(WHERE_AND);
20491                            }
20492    
20493                            for (int i = 0; i < orderByConditionFields.length; i++) {
20494                                    if (getDB().isSupportsInlineDistinct()) {
20495                                            query.append(_ORDER_BY_ENTITY_ALIAS);
20496                                    }
20497                                    else {
20498                                            query.append(_ORDER_BY_ENTITY_TABLE);
20499                                    }
20500    
20501                                    query.append(orderByConditionFields[i]);
20502    
20503                                    if ((i + 1) < orderByConditionFields.length) {
20504                                            if (orderByComparator.isAscending() ^ previous) {
20505                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
20506                                            }
20507                                            else {
20508                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
20509                                            }
20510                                    }
20511                                    else {
20512                                            if (orderByComparator.isAscending() ^ previous) {
20513                                                    query.append(WHERE_GREATER_THAN);
20514                                            }
20515                                            else {
20516                                                    query.append(WHERE_LESSER_THAN);
20517                                            }
20518                                    }
20519                            }
20520    
20521                            query.append(ORDER_BY_CLAUSE);
20522    
20523                            String[] orderByFields = orderByComparator.getOrderByFields();
20524    
20525                            for (int i = 0; i < orderByFields.length; i++) {
20526                                    if (getDB().isSupportsInlineDistinct()) {
20527                                            query.append(_ORDER_BY_ENTITY_ALIAS);
20528                                    }
20529                                    else {
20530                                            query.append(_ORDER_BY_ENTITY_TABLE);
20531                                    }
20532    
20533                                    query.append(orderByFields[i]);
20534    
20535                                    if ((i + 1) < orderByFields.length) {
20536                                            if (orderByComparator.isAscending() ^ previous) {
20537                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
20538                                            }
20539                                            else {
20540                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
20541                                            }
20542                                    }
20543                                    else {
20544                                            if (orderByComparator.isAscending() ^ previous) {
20545                                                    query.append(ORDER_BY_ASC);
20546                                            }
20547                                            else {
20548                                                    query.append(ORDER_BY_DESC);
20549                                            }
20550                                    }
20551                            }
20552                    }
20553                    else {
20554                            if (getDB().isSupportsInlineDistinct()) {
20555                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20556                            }
20557                            else {
20558                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
20559                            }
20560                    }
20561    
20562                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20563                                    JournalArticle.class.getName(),
20564                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20565    
20566                    SQLQuery q = session.createSQLQuery(sql);
20567    
20568                    q.setFirstResult(0);
20569                    q.setMaxResults(2);
20570    
20571                    if (getDB().isSupportsInlineDistinct()) {
20572                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
20573                    }
20574                    else {
20575                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
20576                    }
20577    
20578                    QueryPos qPos = QueryPos.getInstance(q);
20579    
20580                    qPos.add(groupId);
20581    
20582                    qPos.add(classNameId);
20583    
20584                    if (bindLayoutUuid) {
20585                            qPos.add(layoutUuid);
20586                    }
20587    
20588                    if (orderByComparator != null) {
20589                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
20590    
20591                            for (Object value : values) {
20592                                    qPos.add(value);
20593                            }
20594                    }
20595    
20596                    List<JournalArticle> list = q.list();
20597    
20598                    if (list.size() == 2) {
20599                            return list.get(1);
20600                    }
20601                    else {
20602                            return null;
20603                    }
20604            }
20605    
20606            /**
20607             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63; from the database.
20608             *
20609             * @param groupId the group ID
20610             * @param classNameId the class name ID
20611             * @param layoutUuid the layout uuid
20612             * @throws SystemException if a system exception occurred
20613             */
20614            public void removeByG_C_L(long groupId, long classNameId, String layoutUuid)
20615                    throws SystemException {
20616                    for (JournalArticle journalArticle : findByG_C_L(groupId, classNameId,
20617                                    layoutUuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
20618                            remove(journalArticle);
20619                    }
20620            }
20621    
20622            /**
20623             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
20624             *
20625             * @param groupId the group ID
20626             * @param classNameId the class name ID
20627             * @param layoutUuid the layout uuid
20628             * @return the number of matching journal articles
20629             * @throws SystemException if a system exception occurred
20630             */
20631            public int countByG_C_L(long groupId, long classNameId, String layoutUuid)
20632                    throws SystemException {
20633                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_L;
20634    
20635                    Object[] finderArgs = new Object[] { groupId, classNameId, layoutUuid };
20636    
20637                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
20638                                    this);
20639    
20640                    if (count == null) {
20641                            StringBundler query = new StringBundler(4);
20642    
20643                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
20644    
20645                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
20646    
20647                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
20648    
20649                            boolean bindLayoutUuid = false;
20650    
20651                            if (layoutUuid == null) {
20652                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
20653                            }
20654                            else if (layoutUuid.equals(StringPool.BLANK)) {
20655                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
20656                            }
20657                            else {
20658                                    bindLayoutUuid = true;
20659    
20660                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
20661                            }
20662    
20663                            String sql = query.toString();
20664    
20665                            Session session = null;
20666    
20667                            try {
20668                                    session = openSession();
20669    
20670                                    Query q = session.createQuery(sql);
20671    
20672                                    QueryPos qPos = QueryPos.getInstance(q);
20673    
20674                                    qPos.add(groupId);
20675    
20676                                    qPos.add(classNameId);
20677    
20678                                    if (bindLayoutUuid) {
20679                                            qPos.add(layoutUuid);
20680                                    }
20681    
20682                                    count = (Long)q.uniqueResult();
20683    
20684                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
20685                            }
20686                            catch (Exception e) {
20687                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
20688    
20689                                    throw processException(e);
20690                            }
20691                            finally {
20692                                    closeSession(session);
20693                            }
20694                    }
20695    
20696                    return count.intValue();
20697            }
20698    
20699            /**
20700             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
20701             *
20702             * @param groupId the group ID
20703             * @param classNameId the class name ID
20704             * @param layoutUuid the layout uuid
20705             * @return the number of matching journal articles that the user has permission to view
20706             * @throws SystemException if a system exception occurred
20707             */
20708            public int filterCountByG_C_L(long groupId, long classNameId,
20709                    String layoutUuid) throws SystemException {
20710                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20711                            return countByG_C_L(groupId, classNameId, layoutUuid);
20712                    }
20713    
20714                    StringBundler query = new StringBundler(4);
20715    
20716                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
20717    
20718                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
20719    
20720                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
20721    
20722                    boolean bindLayoutUuid = false;
20723    
20724                    if (layoutUuid == null) {
20725                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
20726                    }
20727                    else if (layoutUuid.equals(StringPool.BLANK)) {
20728                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
20729                    }
20730                    else {
20731                            bindLayoutUuid = true;
20732    
20733                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
20734                    }
20735    
20736                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20737                                    JournalArticle.class.getName(),
20738                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20739    
20740                    Session session = null;
20741    
20742                    try {
20743                            session = openSession();
20744    
20745                            SQLQuery q = session.createSQLQuery(sql);
20746    
20747                            q.addScalar(COUNT_COLUMN_NAME,
20748                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
20749    
20750                            QueryPos qPos = QueryPos.getInstance(q);
20751    
20752                            qPos.add(groupId);
20753    
20754                            qPos.add(classNameId);
20755    
20756                            if (bindLayoutUuid) {
20757                                    qPos.add(layoutUuid);
20758                            }
20759    
20760                            Long count = (Long)q.uniqueResult();
20761    
20762                            return count.intValue();
20763                    }
20764                    catch (Exception e) {
20765                            throw processException(e);
20766                    }
20767                    finally {
20768                            closeSession(session);
20769                    }
20770            }
20771    
20772            private static final String _FINDER_COLUMN_G_C_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
20773            private static final String _FINDER_COLUMN_G_C_L_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
20774            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
20775            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
20776            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = '')";
20777            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
20778                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
20779                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
20780                            "findByG_U_C",
20781                            new String[] {
20782                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
20783                                    
20784                            Integer.class.getName(), Integer.class.getName(),
20785                                    OrderByComparator.class.getName()
20786                            });
20787            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
20788                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
20789                            JournalArticleImpl.class,
20790                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_C",
20791                            new String[] {
20792                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
20793                            },
20794                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
20795                            JournalArticleModelImpl.USERID_COLUMN_BITMASK |
20796                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
20797                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
20798                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
20799            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
20800                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
20801                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_C",
20802                            new String[] {
20803                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
20804                            });
20805    
20806            /**
20807             * Returns all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
20808             *
20809             * @param groupId the group ID
20810             * @param userId the user ID
20811             * @param classNameId the class name ID
20812             * @return the matching journal articles
20813             * @throws SystemException if a system exception occurred
20814             */
20815            public List<JournalArticle> findByG_U_C(long groupId, long userId,
20816                    long classNameId) throws SystemException {
20817                    return findByG_U_C(groupId, userId, classNameId, QueryUtil.ALL_POS,
20818                            QueryUtil.ALL_POS, null);
20819            }
20820    
20821            /**
20822             * Returns a range of all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
20823             *
20824             * <p>
20825             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20826             * </p>
20827             *
20828             * @param groupId the group ID
20829             * @param userId the user ID
20830             * @param classNameId the class name ID
20831             * @param start the lower bound of the range of journal articles
20832             * @param end the upper bound of the range of journal articles (not inclusive)
20833             * @return the range of matching journal articles
20834             * @throws SystemException if a system exception occurred
20835             */
20836            public List<JournalArticle> findByG_U_C(long groupId, long userId,
20837                    long classNameId, int start, int end) throws SystemException {
20838                    return findByG_U_C(groupId, userId, classNameId, start, end, null);
20839            }
20840    
20841            /**
20842             * Returns an ordered range of all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
20843             *
20844             * <p>
20845             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20846             * </p>
20847             *
20848             * @param groupId the group ID
20849             * @param userId the user ID
20850             * @param classNameId the class name ID
20851             * @param start the lower bound of the range of journal articles
20852             * @param end the upper bound of the range of journal articles (not inclusive)
20853             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
20854             * @return the ordered range of matching journal articles
20855             * @throws SystemException if a system exception occurred
20856             */
20857            public List<JournalArticle> findByG_U_C(long groupId, long userId,
20858                    long classNameId, int start, int end,
20859                    OrderByComparator orderByComparator) throws SystemException {
20860                    boolean pagination = true;
20861                    FinderPath finderPath = null;
20862                    Object[] finderArgs = null;
20863    
20864                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
20865                                    (orderByComparator == null)) {
20866                            pagination = false;
20867                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C;
20868                            finderArgs = new Object[] { groupId, userId, classNameId };
20869                    }
20870                    else {
20871                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_C;
20872                            finderArgs = new Object[] {
20873                                            groupId, userId, classNameId,
20874                                            
20875                                            start, end, orderByComparator
20876                                    };
20877                    }
20878    
20879                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
20880                                    finderArgs, this);
20881    
20882                    if ((list != null) && !list.isEmpty()) {
20883                            for (JournalArticle journalArticle : list) {
20884                                    if ((groupId != journalArticle.getGroupId()) ||
20885                                                    (userId != journalArticle.getUserId()) ||
20886                                                    (classNameId != journalArticle.getClassNameId())) {
20887                                            list = null;
20888    
20889                                            break;
20890                                    }
20891                            }
20892                    }
20893    
20894                    if (list == null) {
20895                            StringBundler query = null;
20896    
20897                            if (orderByComparator != null) {
20898                                    query = new StringBundler(5 +
20899                                                    (orderByComparator.getOrderByFields().length * 3));
20900                            }
20901                            else {
20902                                    query = new StringBundler(5);
20903                            }
20904    
20905                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
20906    
20907                            query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
20908    
20909                            query.append(_FINDER_COLUMN_G_U_C_USERID_2);
20910    
20911                            query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
20912    
20913                            if (orderByComparator != null) {
20914                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
20915                                            orderByComparator);
20916                            }
20917                            else
20918                             if (pagination) {
20919                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20920                            }
20921    
20922                            String sql = query.toString();
20923    
20924                            Session session = null;
20925    
20926                            try {
20927                                    session = openSession();
20928    
20929                                    Query q = session.createQuery(sql);
20930    
20931                                    QueryPos qPos = QueryPos.getInstance(q);
20932    
20933                                    qPos.add(groupId);
20934    
20935                                    qPos.add(userId);
20936    
20937                                    qPos.add(classNameId);
20938    
20939                                    if (!pagination) {
20940                                            list = (List<JournalArticle>)QueryUtil.list(q,
20941                                                            getDialect(), start, end, false);
20942    
20943                                            Collections.sort(list);
20944    
20945                                            list = new UnmodifiableList<JournalArticle>(list);
20946                                    }
20947                                    else {
20948                                            list = (List<JournalArticle>)QueryUtil.list(q,
20949                                                            getDialect(), start, end);
20950                                    }
20951    
20952                                    cacheResult(list);
20953    
20954                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
20955                            }
20956                            catch (Exception e) {
20957                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
20958    
20959                                    throw processException(e);
20960                            }
20961                            finally {
20962                                    closeSession(session);
20963                            }
20964                    }
20965    
20966                    return list;
20967            }
20968    
20969            /**
20970             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
20971             *
20972             * @param groupId the group ID
20973             * @param userId the user ID
20974             * @param classNameId the class name ID
20975             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20976             * @return the first matching journal article
20977             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
20978             * @throws SystemException if a system exception occurred
20979             */
20980            public JournalArticle findByG_U_C_First(long groupId, long userId,
20981                    long classNameId, OrderByComparator orderByComparator)
20982                    throws NoSuchArticleException, SystemException {
20983                    JournalArticle journalArticle = fetchByG_U_C_First(groupId, userId,
20984                                    classNameId, orderByComparator);
20985    
20986                    if (journalArticle != null) {
20987                            return journalArticle;
20988                    }
20989    
20990                    StringBundler msg = new StringBundler(8);
20991    
20992                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
20993    
20994                    msg.append("groupId=");
20995                    msg.append(groupId);
20996    
20997                    msg.append(", userId=");
20998                    msg.append(userId);
20999    
21000                    msg.append(", classNameId=");
21001                    msg.append(classNameId);
21002    
21003                    msg.append(StringPool.CLOSE_CURLY_BRACE);
21004    
21005                    throw new NoSuchArticleException(msg.toString());
21006            }
21007    
21008            /**
21009             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
21010             *
21011             * @param groupId the group ID
21012             * @param userId the user ID
21013             * @param classNameId the class name ID
21014             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21015             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
21016             * @throws SystemException if a system exception occurred
21017             */
21018            public JournalArticle fetchByG_U_C_First(long groupId, long userId,
21019                    long classNameId, OrderByComparator orderByComparator)
21020                    throws SystemException {
21021                    List<JournalArticle> list = findByG_U_C(groupId, userId, classNameId,
21022                                    0, 1, orderByComparator);
21023    
21024                    if (!list.isEmpty()) {
21025                            return list.get(0);
21026                    }
21027    
21028                    return null;
21029            }
21030    
21031            /**
21032             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
21033             *
21034             * @param groupId the group ID
21035             * @param userId the user ID
21036             * @param classNameId the class name ID
21037             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21038             * @return the last matching journal article
21039             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
21040             * @throws SystemException if a system exception occurred
21041             */
21042            public JournalArticle findByG_U_C_Last(long groupId, long userId,
21043                    long classNameId, OrderByComparator orderByComparator)
21044                    throws NoSuchArticleException, SystemException {
21045                    JournalArticle journalArticle = fetchByG_U_C_Last(groupId, userId,
21046                                    classNameId, orderByComparator);
21047    
21048                    if (journalArticle != null) {
21049                            return journalArticle;
21050                    }
21051    
21052                    StringBundler msg = new StringBundler(8);
21053    
21054                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
21055    
21056                    msg.append("groupId=");
21057                    msg.append(groupId);
21058    
21059                    msg.append(", userId=");
21060                    msg.append(userId);
21061    
21062                    msg.append(", classNameId=");
21063                    msg.append(classNameId);
21064    
21065                    msg.append(StringPool.CLOSE_CURLY_BRACE);
21066    
21067                    throw new NoSuchArticleException(msg.toString());
21068            }
21069    
21070            /**
21071             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
21072             *
21073             * @param groupId the group ID
21074             * @param userId the user ID
21075             * @param classNameId the class name ID
21076             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21077             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
21078             * @throws SystemException if a system exception occurred
21079             */
21080            public JournalArticle fetchByG_U_C_Last(long groupId, long userId,
21081                    long classNameId, OrderByComparator orderByComparator)
21082                    throws SystemException {
21083                    int count = countByG_U_C(groupId, userId, classNameId);
21084    
21085                    List<JournalArticle> list = findByG_U_C(groupId, userId, classNameId,
21086                                    count - 1, count, orderByComparator);
21087    
21088                    if (!list.isEmpty()) {
21089                            return list.get(0);
21090                    }
21091    
21092                    return null;
21093            }
21094    
21095            /**
21096             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
21097             *
21098             * @param id the primary key of the current journal article
21099             * @param groupId the group ID
21100             * @param userId the user ID
21101             * @param classNameId the class name ID
21102             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21103             * @return the previous, current, and next journal article
21104             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
21105             * @throws SystemException if a system exception occurred
21106             */
21107            public JournalArticle[] findByG_U_C_PrevAndNext(long id, long groupId,
21108                    long userId, long classNameId, OrderByComparator orderByComparator)
21109                    throws NoSuchArticleException, SystemException {
21110                    JournalArticle journalArticle = findByPrimaryKey(id);
21111    
21112                    Session session = null;
21113    
21114                    try {
21115                            session = openSession();
21116    
21117                            JournalArticle[] array = new JournalArticleImpl[3];
21118    
21119                            array[0] = getByG_U_C_PrevAndNext(session, journalArticle, groupId,
21120                                            userId, classNameId, orderByComparator, true);
21121    
21122                            array[1] = journalArticle;
21123    
21124                            array[2] = getByG_U_C_PrevAndNext(session, journalArticle, groupId,
21125                                            userId, classNameId, orderByComparator, false);
21126    
21127                            return array;
21128                    }
21129                    catch (Exception e) {
21130                            throw processException(e);
21131                    }
21132                    finally {
21133                            closeSession(session);
21134                    }
21135            }
21136    
21137            protected JournalArticle getByG_U_C_PrevAndNext(Session session,
21138                    JournalArticle journalArticle, long groupId, long userId,
21139                    long classNameId, OrderByComparator orderByComparator, boolean previous) {
21140                    StringBundler query = null;
21141    
21142                    if (orderByComparator != null) {
21143                            query = new StringBundler(6 +
21144                                            (orderByComparator.getOrderByFields().length * 6));
21145                    }
21146                    else {
21147                            query = new StringBundler(3);
21148                    }
21149    
21150                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
21151    
21152                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
21153    
21154                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
21155    
21156                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
21157    
21158                    if (orderByComparator != null) {
21159                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
21160    
21161                            if (orderByConditionFields.length > 0) {
21162                                    query.append(WHERE_AND);
21163                            }
21164    
21165                            for (int i = 0; i < orderByConditionFields.length; i++) {
21166                                    query.append(_ORDER_BY_ENTITY_ALIAS);
21167                                    query.append(orderByConditionFields[i]);
21168    
21169                                    if ((i + 1) < orderByConditionFields.length) {
21170                                            if (orderByComparator.isAscending() ^ previous) {
21171                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
21172                                            }
21173                                            else {
21174                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
21175                                            }
21176                                    }
21177                                    else {
21178                                            if (orderByComparator.isAscending() ^ previous) {
21179                                                    query.append(WHERE_GREATER_THAN);
21180                                            }
21181                                            else {
21182                                                    query.append(WHERE_LESSER_THAN);
21183                                            }
21184                                    }
21185                            }
21186    
21187                            query.append(ORDER_BY_CLAUSE);
21188    
21189                            String[] orderByFields = orderByComparator.getOrderByFields();
21190    
21191                            for (int i = 0; i < orderByFields.length; i++) {
21192                                    query.append(_ORDER_BY_ENTITY_ALIAS);
21193                                    query.append(orderByFields[i]);
21194    
21195                                    if ((i + 1) < orderByFields.length) {
21196                                            if (orderByComparator.isAscending() ^ previous) {
21197                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
21198                                            }
21199                                            else {
21200                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
21201                                            }
21202                                    }
21203                                    else {
21204                                            if (orderByComparator.isAscending() ^ previous) {
21205                                                    query.append(ORDER_BY_ASC);
21206                                            }
21207                                            else {
21208                                                    query.append(ORDER_BY_DESC);
21209                                            }
21210                                    }
21211                            }
21212                    }
21213                    else {
21214                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21215                    }
21216    
21217                    String sql = query.toString();
21218    
21219                    Query q = session.createQuery(sql);
21220    
21221                    q.setFirstResult(0);
21222                    q.setMaxResults(2);
21223    
21224                    QueryPos qPos = QueryPos.getInstance(q);
21225    
21226                    qPos.add(groupId);
21227    
21228                    qPos.add(userId);
21229    
21230                    qPos.add(classNameId);
21231    
21232                    if (orderByComparator != null) {
21233                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
21234    
21235                            for (Object value : values) {
21236                                    qPos.add(value);
21237                            }
21238                    }
21239    
21240                    List<JournalArticle> list = q.list();
21241    
21242                    if (list.size() == 2) {
21243                            return list.get(1);
21244                    }
21245                    else {
21246                            return null;
21247                    }
21248            }
21249    
21250            /**
21251             * Returns all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
21252             *
21253             * @param groupId the group ID
21254             * @param userId the user ID
21255             * @param classNameId the class name ID
21256             * @return the matching journal articles that the user has permission to view
21257             * @throws SystemException if a system exception occurred
21258             */
21259            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
21260                    long classNameId) throws SystemException {
21261                    return filterFindByG_U_C(groupId, userId, classNameId,
21262                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
21263            }
21264    
21265            /**
21266             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
21267             *
21268             * <p>
21269             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
21270             * </p>
21271             *
21272             * @param groupId the group ID
21273             * @param userId the user ID
21274             * @param classNameId the class name ID
21275             * @param start the lower bound of the range of journal articles
21276             * @param end the upper bound of the range of journal articles (not inclusive)
21277             * @return the range of matching journal articles that the user has permission to view
21278             * @throws SystemException if a system exception occurred
21279             */
21280            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
21281                    long classNameId, int start, int end) throws SystemException {
21282                    return filterFindByG_U_C(groupId, userId, classNameId, start, end, null);
21283            }
21284    
21285            /**
21286             * 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;.
21287             *
21288             * <p>
21289             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
21290             * </p>
21291             *
21292             * @param groupId the group ID
21293             * @param userId the user ID
21294             * @param classNameId the class name ID
21295             * @param start the lower bound of the range of journal articles
21296             * @param end the upper bound of the range of journal articles (not inclusive)
21297             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
21298             * @return the ordered range of matching journal articles that the user has permission to view
21299             * @throws SystemException if a system exception occurred
21300             */
21301            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
21302                    long classNameId, int start, int end,
21303                    OrderByComparator orderByComparator) throws SystemException {
21304                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21305                            return findByG_U_C(groupId, userId, classNameId, start, end,
21306                                    orderByComparator);
21307                    }
21308    
21309                    StringBundler query = null;
21310    
21311                    if (orderByComparator != null) {
21312                            query = new StringBundler(5 +
21313                                            (orderByComparator.getOrderByFields().length * 3));
21314                    }
21315                    else {
21316                            query = new StringBundler(5);
21317                    }
21318    
21319                    if (getDB().isSupportsInlineDistinct()) {
21320                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
21321                    }
21322                    else {
21323                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
21324                    }
21325    
21326                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
21327    
21328                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
21329    
21330                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
21331    
21332                    if (!getDB().isSupportsInlineDistinct()) {
21333                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
21334                    }
21335    
21336                    if (orderByComparator != null) {
21337                            if (getDB().isSupportsInlineDistinct()) {
21338                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
21339                                            orderByComparator);
21340                            }
21341                            else {
21342                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
21343                                            orderByComparator);
21344                            }
21345                    }
21346                    else {
21347                            if (getDB().isSupportsInlineDistinct()) {
21348                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21349                            }
21350                            else {
21351                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
21352                            }
21353                    }
21354    
21355                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21356                                    JournalArticle.class.getName(),
21357                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21358    
21359                    Session session = null;
21360    
21361                    try {
21362                            session = openSession();
21363    
21364                            SQLQuery q = session.createSQLQuery(sql);
21365    
21366                            if (getDB().isSupportsInlineDistinct()) {
21367                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
21368                            }
21369                            else {
21370                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
21371                            }
21372    
21373                            QueryPos qPos = QueryPos.getInstance(q);
21374    
21375                            qPos.add(groupId);
21376    
21377                            qPos.add(userId);
21378    
21379                            qPos.add(classNameId);
21380    
21381                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
21382                                    end);
21383                    }
21384                    catch (Exception e) {
21385                            throw processException(e);
21386                    }
21387                    finally {
21388                            closeSession(session);
21389                    }
21390            }
21391    
21392            /**
21393             * 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;.
21394             *
21395             * @param id the primary key of the current journal article
21396             * @param groupId the group ID
21397             * @param userId the user ID
21398             * @param classNameId the class name ID
21399             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21400             * @return the previous, current, and next journal article
21401             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
21402             * @throws SystemException if a system exception occurred
21403             */
21404            public JournalArticle[] filterFindByG_U_C_PrevAndNext(long id,
21405                    long groupId, long userId, long classNameId,
21406                    OrderByComparator orderByComparator)
21407                    throws NoSuchArticleException, SystemException {
21408                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21409                            return findByG_U_C_PrevAndNext(id, groupId, userId, classNameId,
21410                                    orderByComparator);
21411                    }
21412    
21413                    JournalArticle journalArticle = findByPrimaryKey(id);
21414    
21415                    Session session = null;
21416    
21417                    try {
21418                            session = openSession();
21419    
21420                            JournalArticle[] array = new JournalArticleImpl[3];
21421    
21422                            array[0] = filterGetByG_U_C_PrevAndNext(session, journalArticle,
21423                                            groupId, userId, classNameId, orderByComparator, true);
21424    
21425                            array[1] = journalArticle;
21426    
21427                            array[2] = filterGetByG_U_C_PrevAndNext(session, journalArticle,
21428                                            groupId, userId, classNameId, orderByComparator, false);
21429    
21430                            return array;
21431                    }
21432                    catch (Exception e) {
21433                            throw processException(e);
21434                    }
21435                    finally {
21436                            closeSession(session);
21437                    }
21438            }
21439    
21440            protected JournalArticle filterGetByG_U_C_PrevAndNext(Session session,
21441                    JournalArticle journalArticle, long groupId, long userId,
21442                    long classNameId, OrderByComparator orderByComparator, boolean previous) {
21443                    StringBundler query = null;
21444    
21445                    if (orderByComparator != null) {
21446                            query = new StringBundler(6 +
21447                                            (orderByComparator.getOrderByFields().length * 6));
21448                    }
21449                    else {
21450                            query = new StringBundler(3);
21451                    }
21452    
21453                    if (getDB().isSupportsInlineDistinct()) {
21454                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
21455                    }
21456                    else {
21457                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
21458                    }
21459    
21460                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
21461    
21462                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
21463    
21464                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
21465    
21466                    if (!getDB().isSupportsInlineDistinct()) {
21467                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
21468                    }
21469    
21470                    if (orderByComparator != null) {
21471                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
21472    
21473                            if (orderByConditionFields.length > 0) {
21474                                    query.append(WHERE_AND);
21475                            }
21476    
21477                            for (int i = 0; i < orderByConditionFields.length; i++) {
21478                                    if (getDB().isSupportsInlineDistinct()) {
21479                                            query.append(_ORDER_BY_ENTITY_ALIAS);
21480                                    }
21481                                    else {
21482                                            query.append(_ORDER_BY_ENTITY_TABLE);
21483                                    }
21484    
21485                                    query.append(orderByConditionFields[i]);
21486    
21487                                    if ((i + 1) < orderByConditionFields.length) {
21488                                            if (orderByComparator.isAscending() ^ previous) {
21489                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
21490                                            }
21491                                            else {
21492                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
21493                                            }
21494                                    }
21495                                    else {
21496                                            if (orderByComparator.isAscending() ^ previous) {
21497                                                    query.append(WHERE_GREATER_THAN);
21498                                            }
21499                                            else {
21500                                                    query.append(WHERE_LESSER_THAN);
21501                                            }
21502                                    }
21503                            }
21504    
21505                            query.append(ORDER_BY_CLAUSE);
21506    
21507                            String[] orderByFields = orderByComparator.getOrderByFields();
21508    
21509                            for (int i = 0; i < orderByFields.length; i++) {
21510                                    if (getDB().isSupportsInlineDistinct()) {
21511                                            query.append(_ORDER_BY_ENTITY_ALIAS);
21512                                    }
21513                                    else {
21514                                            query.append(_ORDER_BY_ENTITY_TABLE);
21515                                    }
21516    
21517                                    query.append(orderByFields[i]);
21518    
21519                                    if ((i + 1) < orderByFields.length) {
21520                                            if (orderByComparator.isAscending() ^ previous) {
21521                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
21522                                            }
21523                                            else {
21524                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
21525                                            }
21526                                    }
21527                                    else {
21528                                            if (orderByComparator.isAscending() ^ previous) {
21529                                                    query.append(ORDER_BY_ASC);
21530                                            }
21531                                            else {
21532                                                    query.append(ORDER_BY_DESC);
21533                                            }
21534                                    }
21535                            }
21536                    }
21537                    else {
21538                            if (getDB().isSupportsInlineDistinct()) {
21539                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21540                            }
21541                            else {
21542                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
21543                            }
21544                    }
21545    
21546                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21547                                    JournalArticle.class.getName(),
21548                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21549    
21550                    SQLQuery q = session.createSQLQuery(sql);
21551    
21552                    q.setFirstResult(0);
21553                    q.setMaxResults(2);
21554    
21555                    if (getDB().isSupportsInlineDistinct()) {
21556                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
21557                    }
21558                    else {
21559                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
21560                    }
21561    
21562                    QueryPos qPos = QueryPos.getInstance(q);
21563    
21564                    qPos.add(groupId);
21565    
21566                    qPos.add(userId);
21567    
21568                    qPos.add(classNameId);
21569    
21570                    if (orderByComparator != null) {
21571                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
21572    
21573                            for (Object value : values) {
21574                                    qPos.add(value);
21575                            }
21576                    }
21577    
21578                    List<JournalArticle> list = q.list();
21579    
21580                    if (list.size() == 2) {
21581                            return list.get(1);
21582                    }
21583                    else {
21584                            return null;
21585                    }
21586            }
21587    
21588            /**
21589             * Removes all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63; from the database.
21590             *
21591             * @param groupId the group ID
21592             * @param userId the user ID
21593             * @param classNameId the class name ID
21594             * @throws SystemException if a system exception occurred
21595             */
21596            public void removeByG_U_C(long groupId, long userId, long classNameId)
21597                    throws SystemException {
21598                    for (JournalArticle journalArticle : findByG_U_C(groupId, userId,
21599                                    classNameId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
21600                            remove(journalArticle);
21601                    }
21602            }
21603    
21604            /**
21605             * Returns the number of journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
21606             *
21607             * @param groupId the group ID
21608             * @param userId the user ID
21609             * @param classNameId the class name ID
21610             * @return the number of matching journal articles
21611             * @throws SystemException if a system exception occurred
21612             */
21613            public int countByG_U_C(long groupId, long userId, long classNameId)
21614                    throws SystemException {
21615                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_C;
21616    
21617                    Object[] finderArgs = new Object[] { groupId, userId, classNameId };
21618    
21619                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
21620                                    this);
21621    
21622                    if (count == null) {
21623                            StringBundler query = new StringBundler(4);
21624    
21625                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
21626    
21627                            query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
21628    
21629                            query.append(_FINDER_COLUMN_G_U_C_USERID_2);
21630    
21631                            query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
21632    
21633                            String sql = query.toString();
21634    
21635                            Session session = null;
21636    
21637                            try {
21638                                    session = openSession();
21639    
21640                                    Query q = session.createQuery(sql);
21641    
21642                                    QueryPos qPos = QueryPos.getInstance(q);
21643    
21644                                    qPos.add(groupId);
21645    
21646                                    qPos.add(userId);
21647    
21648                                    qPos.add(classNameId);
21649    
21650                                    count = (Long)q.uniqueResult();
21651    
21652                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
21653                            }
21654                            catch (Exception e) {
21655                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
21656    
21657                                    throw processException(e);
21658                            }
21659                            finally {
21660                                    closeSession(session);
21661                            }
21662                    }
21663    
21664                    return count.intValue();
21665            }
21666    
21667            /**
21668             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
21669             *
21670             * @param groupId the group ID
21671             * @param userId the user ID
21672             * @param classNameId the class name ID
21673             * @return the number of matching journal articles that the user has permission to view
21674             * @throws SystemException if a system exception occurred
21675             */
21676            public int filterCountByG_U_C(long groupId, long userId, long classNameId)
21677                    throws SystemException {
21678                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21679                            return countByG_U_C(groupId, userId, classNameId);
21680                    }
21681    
21682                    StringBundler query = new StringBundler(4);
21683    
21684                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
21685    
21686                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
21687    
21688                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
21689    
21690                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
21691    
21692                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21693                                    JournalArticle.class.getName(),
21694                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21695    
21696                    Session session = null;
21697    
21698                    try {
21699                            session = openSession();
21700    
21701                            SQLQuery q = session.createSQLQuery(sql);
21702    
21703                            q.addScalar(COUNT_COLUMN_NAME,
21704                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
21705    
21706                            QueryPos qPos = QueryPos.getInstance(q);
21707    
21708                            qPos.add(groupId);
21709    
21710                            qPos.add(userId);
21711    
21712                            qPos.add(classNameId);
21713    
21714                            Long count = (Long)q.uniqueResult();
21715    
21716                            return count.intValue();
21717                    }
21718                    catch (Exception e) {
21719                            throw processException(e);
21720                    }
21721                    finally {
21722                            closeSession(session);
21723                    }
21724            }
21725    
21726            private static final String _FINDER_COLUMN_G_U_C_GROUPID_2 = "journalArticle.groupId = ? AND ";
21727            private static final String _FINDER_COLUMN_G_U_C_USERID_2 = "journalArticle.userId = ? AND ";
21728            private static final String _FINDER_COLUMN_G_U_C_CLASSNAMEID_2 = "journalArticle.classNameId = ?";
21729            public static final FinderPath FINDER_PATH_FETCH_BY_G_A_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
21730                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
21731                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_A_V",
21732                            new String[] {
21733                                    Long.class.getName(), String.class.getName(),
21734                                    Double.class.getName()
21735                            },
21736                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
21737                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
21738                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
21739            public static final FinderPath FINDER_PATH_COUNT_BY_G_A_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
21740                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
21741                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A_V",
21742                            new String[] {
21743                                    Long.class.getName(), String.class.getName(),
21744                                    Double.class.getName()
21745                            });
21746    
21747            /**
21748             * 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.
21749             *
21750             * @param groupId the group ID
21751             * @param articleId the article ID
21752             * @param version the version
21753             * @return the matching journal article
21754             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
21755             * @throws SystemException if a system exception occurred
21756             */
21757            public JournalArticle findByG_A_V(long groupId, String articleId,
21758                    double version) throws NoSuchArticleException, SystemException {
21759                    JournalArticle journalArticle = fetchByG_A_V(groupId, articleId, version);
21760    
21761                    if (journalArticle == null) {
21762                            StringBundler msg = new StringBundler(8);
21763    
21764                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
21765    
21766                            msg.append("groupId=");
21767                            msg.append(groupId);
21768    
21769                            msg.append(", articleId=");
21770                            msg.append(articleId);
21771    
21772                            msg.append(", version=");
21773                            msg.append(version);
21774    
21775                            msg.append(StringPool.CLOSE_CURLY_BRACE);
21776    
21777                            if (_log.isWarnEnabled()) {
21778                                    _log.warn(msg.toString());
21779                            }
21780    
21781                            throw new NoSuchArticleException(msg.toString());
21782                    }
21783    
21784                    return journalArticle;
21785            }
21786    
21787            /**
21788             * 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.
21789             *
21790             * @param groupId the group ID
21791             * @param articleId the article ID
21792             * @param version the version
21793             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
21794             * @throws SystemException if a system exception occurred
21795             */
21796            public JournalArticle fetchByG_A_V(long groupId, String articleId,
21797                    double version) throws SystemException {
21798                    return fetchByG_A_V(groupId, articleId, version, true);
21799            }
21800    
21801            /**
21802             * 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.
21803             *
21804             * @param groupId the group ID
21805             * @param articleId the article ID
21806             * @param version the version
21807             * @param retrieveFromCache whether to use the finder cache
21808             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
21809             * @throws SystemException if a system exception occurred
21810             */
21811            public JournalArticle fetchByG_A_V(long groupId, String articleId,
21812                    double version, boolean retrieveFromCache) throws SystemException {
21813                    Object[] finderArgs = new Object[] { groupId, articleId, version };
21814    
21815                    Object result = null;
21816    
21817                    if (retrieveFromCache) {
21818                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_A_V,
21819                                            finderArgs, this);
21820                    }
21821    
21822                    if (result instanceof JournalArticle) {
21823                            JournalArticle journalArticle = (JournalArticle)result;
21824    
21825                            if ((groupId != journalArticle.getGroupId()) ||
21826                                            !Validator.equals(articleId, journalArticle.getArticleId()) ||
21827                                            (version != journalArticle.getVersion())) {
21828                                    result = null;
21829                            }
21830                    }
21831    
21832                    if (result == null) {
21833                            StringBundler query = new StringBundler(5);
21834    
21835                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
21836    
21837                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
21838    
21839                            boolean bindArticleId = false;
21840    
21841                            if (articleId == null) {
21842                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
21843                            }
21844                            else if (articleId.equals(StringPool.BLANK)) {
21845                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
21846                            }
21847                            else {
21848                                    bindArticleId = true;
21849    
21850                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
21851                            }
21852    
21853                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
21854    
21855                            String sql = query.toString();
21856    
21857                            Session session = null;
21858    
21859                            try {
21860                                    session = openSession();
21861    
21862                                    Query q = session.createQuery(sql);
21863    
21864                                    QueryPos qPos = QueryPos.getInstance(q);
21865    
21866                                    qPos.add(groupId);
21867    
21868                                    if (bindArticleId) {
21869                                            qPos.add(articleId);
21870                                    }
21871    
21872                                    qPos.add(version);
21873    
21874                                    List<JournalArticle> list = q.list();
21875    
21876                                    if (list.isEmpty()) {
21877                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
21878                                                    finderArgs, list);
21879                                    }
21880                                    else {
21881                                            JournalArticle journalArticle = list.get(0);
21882    
21883                                            result = journalArticle;
21884    
21885                                            cacheResult(journalArticle);
21886    
21887                                            if ((journalArticle.getGroupId() != groupId) ||
21888                                                            (journalArticle.getArticleId() == null) ||
21889                                                            !journalArticle.getArticleId().equals(articleId) ||
21890                                                            (journalArticle.getVersion() != version)) {
21891                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
21892                                                            finderArgs, journalArticle);
21893                                            }
21894                                    }
21895                            }
21896                            catch (Exception e) {
21897                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V,
21898                                            finderArgs);
21899    
21900                                    throw processException(e);
21901                            }
21902                            finally {
21903                                    closeSession(session);
21904                            }
21905                    }
21906    
21907                    if (result instanceof List<?>) {
21908                            return null;
21909                    }
21910                    else {
21911                            return (JournalArticle)result;
21912                    }
21913            }
21914    
21915            /**
21916             * Removes the journal article where groupId = &#63; and articleId = &#63; and version = &#63; from the database.
21917             *
21918             * @param groupId the group ID
21919             * @param articleId the article ID
21920             * @param version the version
21921             * @return the journal article that was removed
21922             * @throws SystemException if a system exception occurred
21923             */
21924            public JournalArticle removeByG_A_V(long groupId, String articleId,
21925                    double version) throws NoSuchArticleException, SystemException {
21926                    JournalArticle journalArticle = findByG_A_V(groupId, articleId, version);
21927    
21928                    return remove(journalArticle);
21929            }
21930    
21931            /**
21932             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and version = &#63;.
21933             *
21934             * @param groupId the group ID
21935             * @param articleId the article ID
21936             * @param version the version
21937             * @return the number of matching journal articles
21938             * @throws SystemException if a system exception occurred
21939             */
21940            public int countByG_A_V(long groupId, String articleId, double version)
21941                    throws SystemException {
21942                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A_V;
21943    
21944                    Object[] finderArgs = new Object[] { groupId, articleId, version };
21945    
21946                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
21947                                    this);
21948    
21949                    if (count == null) {
21950                            StringBundler query = new StringBundler(4);
21951    
21952                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
21953    
21954                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
21955    
21956                            boolean bindArticleId = false;
21957    
21958                            if (articleId == null) {
21959                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
21960                            }
21961                            else if (articleId.equals(StringPool.BLANK)) {
21962                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
21963                            }
21964                            else {
21965                                    bindArticleId = true;
21966    
21967                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
21968                            }
21969    
21970                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
21971    
21972                            String sql = query.toString();
21973    
21974                            Session session = null;
21975    
21976                            try {
21977                                    session = openSession();
21978    
21979                                    Query q = session.createQuery(sql);
21980    
21981                                    QueryPos qPos = QueryPos.getInstance(q);
21982    
21983                                    qPos.add(groupId);
21984    
21985                                    if (bindArticleId) {
21986                                            qPos.add(articleId);
21987                                    }
21988    
21989                                    qPos.add(version);
21990    
21991                                    count = (Long)q.uniqueResult();
21992    
21993                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
21994                            }
21995                            catch (Exception e) {
21996                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
21997    
21998                                    throw processException(e);
21999                            }
22000                            finally {
22001                                    closeSession(session);
22002                            }
22003                    }
22004    
22005                    return count.intValue();
22006            }
22007    
22008            private static final String _FINDER_COLUMN_G_A_V_GROUPID_2 = "journalArticle.groupId = ? AND ";
22009            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
22010            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
22011            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '') AND ";
22012            private static final String _FINDER_COLUMN_G_A_V_VERSION_2 = "journalArticle.version = ?";
22013            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22014                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
22015                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
22016                            "findByG_A_ST",
22017                            new String[] {
22018                                    Long.class.getName(), String.class.getName(),
22019                                    Integer.class.getName(),
22020                                    
22021                            Integer.class.getName(), Integer.class.getName(),
22022                                    OrderByComparator.class.getName()
22023                            });
22024            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST =
22025                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22026                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
22027                            JournalArticleImpl.class,
22028                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A_ST",
22029                            new String[] {
22030                                    Long.class.getName(), String.class.getName(),
22031                                    Integer.class.getName()
22032                            },
22033                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
22034                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
22035                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
22036                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
22037            public static final FinderPath FINDER_PATH_COUNT_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22038                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
22039                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A_ST",
22040                            new String[] {
22041                                    Long.class.getName(), String.class.getName(),
22042                                    Integer.class.getName()
22043                            });
22044            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22045                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
22046                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_A_ST",
22047                            new String[] {
22048                                    Long.class.getName(), String.class.getName(),
22049                                    Integer.class.getName()
22050                            });
22051    
22052            /**
22053             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
22054             *
22055             * @param groupId the group ID
22056             * @param articleId the article ID
22057             * @param status the status
22058             * @return the matching journal articles
22059             * @throws SystemException if a system exception occurred
22060             */
22061            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
22062                    int status) throws SystemException {
22063                    return findByG_A_ST(groupId, articleId, status, QueryUtil.ALL_POS,
22064                            QueryUtil.ALL_POS, null);
22065            }
22066    
22067            /**
22068             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
22069             *
22070             * <p>
22071             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22072             * </p>
22073             *
22074             * @param groupId the group ID
22075             * @param articleId the article ID
22076             * @param status the status
22077             * @param start the lower bound of the range of journal articles
22078             * @param end the upper bound of the range of journal articles (not inclusive)
22079             * @return the range of matching journal articles
22080             * @throws SystemException if a system exception occurred
22081             */
22082            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
22083                    int status, int start, int end) throws SystemException {
22084                    return findByG_A_ST(groupId, articleId, status, start, end, null);
22085            }
22086    
22087            /**
22088             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
22089             *
22090             * <p>
22091             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22092             * </p>
22093             *
22094             * @param groupId the group ID
22095             * @param articleId the article ID
22096             * @param status the status
22097             * @param start the lower bound of the range of journal articles
22098             * @param end the upper bound of the range of journal articles (not inclusive)
22099             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
22100             * @return the ordered range of matching journal articles
22101             * @throws SystemException if a system exception occurred
22102             */
22103            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
22104                    int status, int start, int end, OrderByComparator orderByComparator)
22105                    throws SystemException {
22106                    boolean pagination = true;
22107                    FinderPath finderPath = null;
22108                    Object[] finderArgs = null;
22109    
22110                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
22111                                    (orderByComparator == null)) {
22112                            pagination = false;
22113                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST;
22114                            finderArgs = new Object[] { groupId, articleId, status };
22115                    }
22116                    else {
22117                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST;
22118                            finderArgs = new Object[] {
22119                                            groupId, articleId, status,
22120                                            
22121                                            start, end, orderByComparator
22122                                    };
22123                    }
22124    
22125                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
22126                                    finderArgs, this);
22127    
22128                    if ((list != null) && !list.isEmpty()) {
22129                            for (JournalArticle journalArticle : list) {
22130                                    if ((groupId != journalArticle.getGroupId()) ||
22131                                                    !Validator.equals(articleId,
22132                                                            journalArticle.getArticleId()) ||
22133                                                    (status != journalArticle.getStatus())) {
22134                                            list = null;
22135    
22136                                            break;
22137                                    }
22138                            }
22139                    }
22140    
22141                    if (list == null) {
22142                            StringBundler query = null;
22143    
22144                            if (orderByComparator != null) {
22145                                    query = new StringBundler(5 +
22146                                                    (orderByComparator.getOrderByFields().length * 3));
22147                            }
22148                            else {
22149                                    query = new StringBundler(5);
22150                            }
22151    
22152                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
22153    
22154                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
22155    
22156                            boolean bindArticleId = false;
22157    
22158                            if (articleId == null) {
22159                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
22160                            }
22161                            else if (articleId.equals(StringPool.BLANK)) {
22162                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
22163                            }
22164                            else {
22165                                    bindArticleId = true;
22166    
22167                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
22168                            }
22169    
22170                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
22171    
22172                            if (orderByComparator != null) {
22173                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
22174                                            orderByComparator);
22175                            }
22176                            else
22177                             if (pagination) {
22178                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22179                            }
22180    
22181                            String sql = query.toString();
22182    
22183                            Session session = null;
22184    
22185                            try {
22186                                    session = openSession();
22187    
22188                                    Query q = session.createQuery(sql);
22189    
22190                                    QueryPos qPos = QueryPos.getInstance(q);
22191    
22192                                    qPos.add(groupId);
22193    
22194                                    if (bindArticleId) {
22195                                            qPos.add(articleId);
22196                                    }
22197    
22198                                    qPos.add(status);
22199    
22200                                    if (!pagination) {
22201                                            list = (List<JournalArticle>)QueryUtil.list(q,
22202                                                            getDialect(), start, end, false);
22203    
22204                                            Collections.sort(list);
22205    
22206                                            list = new UnmodifiableList<JournalArticle>(list);
22207                                    }
22208                                    else {
22209                                            list = (List<JournalArticle>)QueryUtil.list(q,
22210                                                            getDialect(), start, end);
22211                                    }
22212    
22213                                    cacheResult(list);
22214    
22215                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
22216                            }
22217                            catch (Exception e) {
22218                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
22219    
22220                                    throw processException(e);
22221                            }
22222                            finally {
22223                                    closeSession(session);
22224                            }
22225                    }
22226    
22227                    return list;
22228            }
22229    
22230            /**
22231             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
22232             *
22233             * @param groupId the group ID
22234             * @param articleId the article ID
22235             * @param status the status
22236             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22237             * @return the first matching journal article
22238             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
22239             * @throws SystemException if a system exception occurred
22240             */
22241            public JournalArticle findByG_A_ST_First(long groupId, String articleId,
22242                    int status, OrderByComparator orderByComparator)
22243                    throws NoSuchArticleException, SystemException {
22244                    JournalArticle journalArticle = fetchByG_A_ST_First(groupId, articleId,
22245                                    status, orderByComparator);
22246    
22247                    if (journalArticle != null) {
22248                            return journalArticle;
22249                    }
22250    
22251                    StringBundler msg = new StringBundler(8);
22252    
22253                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
22254    
22255                    msg.append("groupId=");
22256                    msg.append(groupId);
22257    
22258                    msg.append(", articleId=");
22259                    msg.append(articleId);
22260    
22261                    msg.append(", status=");
22262                    msg.append(status);
22263    
22264                    msg.append(StringPool.CLOSE_CURLY_BRACE);
22265    
22266                    throw new NoSuchArticleException(msg.toString());
22267            }
22268    
22269            /**
22270             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
22271             *
22272             * @param groupId the group ID
22273             * @param articleId the article ID
22274             * @param status the status
22275             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22276             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
22277             * @throws SystemException if a system exception occurred
22278             */
22279            public JournalArticle fetchByG_A_ST_First(long groupId, String articleId,
22280                    int status, OrderByComparator orderByComparator)
22281                    throws SystemException {
22282                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status, 0,
22283                                    1, orderByComparator);
22284    
22285                    if (!list.isEmpty()) {
22286                            return list.get(0);
22287                    }
22288    
22289                    return null;
22290            }
22291    
22292            /**
22293             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
22294             *
22295             * @param groupId the group ID
22296             * @param articleId the article ID
22297             * @param status the status
22298             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22299             * @return the last matching journal article
22300             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
22301             * @throws SystemException if a system exception occurred
22302             */
22303            public JournalArticle findByG_A_ST_Last(long groupId, String articleId,
22304                    int status, OrderByComparator orderByComparator)
22305                    throws NoSuchArticleException, SystemException {
22306                    JournalArticle journalArticle = fetchByG_A_ST_Last(groupId, articleId,
22307                                    status, orderByComparator);
22308    
22309                    if (journalArticle != null) {
22310                            return journalArticle;
22311                    }
22312    
22313                    StringBundler msg = new StringBundler(8);
22314    
22315                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
22316    
22317                    msg.append("groupId=");
22318                    msg.append(groupId);
22319    
22320                    msg.append(", articleId=");
22321                    msg.append(articleId);
22322    
22323                    msg.append(", status=");
22324                    msg.append(status);
22325    
22326                    msg.append(StringPool.CLOSE_CURLY_BRACE);
22327    
22328                    throw new NoSuchArticleException(msg.toString());
22329            }
22330    
22331            /**
22332             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
22333             *
22334             * @param groupId the group ID
22335             * @param articleId the article ID
22336             * @param status the status
22337             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22338             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
22339             * @throws SystemException if a system exception occurred
22340             */
22341            public JournalArticle fetchByG_A_ST_Last(long groupId, String articleId,
22342                    int status, OrderByComparator orderByComparator)
22343                    throws SystemException {
22344                    int count = countByG_A_ST(groupId, articleId, status);
22345    
22346                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status,
22347                                    count - 1, count, orderByComparator);
22348    
22349                    if (!list.isEmpty()) {
22350                            return list.get(0);
22351                    }
22352    
22353                    return null;
22354            }
22355    
22356            /**
22357             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
22358             *
22359             * @param id the primary key of the current journal article
22360             * @param groupId the group ID
22361             * @param articleId the article ID
22362             * @param status the status
22363             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22364             * @return the previous, current, and next journal article
22365             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
22366             * @throws SystemException if a system exception occurred
22367             */
22368            public JournalArticle[] findByG_A_ST_PrevAndNext(long id, long groupId,
22369                    String articleId, int status, OrderByComparator orderByComparator)
22370                    throws NoSuchArticleException, SystemException {
22371                    JournalArticle journalArticle = findByPrimaryKey(id);
22372    
22373                    Session session = null;
22374    
22375                    try {
22376                            session = openSession();
22377    
22378                            JournalArticle[] array = new JournalArticleImpl[3];
22379    
22380                            array[0] = getByG_A_ST_PrevAndNext(session, journalArticle,
22381                                            groupId, articleId, status, orderByComparator, true);
22382    
22383                            array[1] = journalArticle;
22384    
22385                            array[2] = getByG_A_ST_PrevAndNext(session, journalArticle,
22386                                            groupId, articleId, status, orderByComparator, false);
22387    
22388                            return array;
22389                    }
22390                    catch (Exception e) {
22391                            throw processException(e);
22392                    }
22393                    finally {
22394                            closeSession(session);
22395                    }
22396            }
22397    
22398            protected JournalArticle getByG_A_ST_PrevAndNext(Session session,
22399                    JournalArticle journalArticle, long groupId, String articleId,
22400                    int status, OrderByComparator orderByComparator, boolean previous) {
22401                    StringBundler query = null;
22402    
22403                    if (orderByComparator != null) {
22404                            query = new StringBundler(6 +
22405                                            (orderByComparator.getOrderByFields().length * 6));
22406                    }
22407                    else {
22408                            query = new StringBundler(3);
22409                    }
22410    
22411                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
22412    
22413                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
22414    
22415                    boolean bindArticleId = false;
22416    
22417                    if (articleId == null) {
22418                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
22419                    }
22420                    else if (articleId.equals(StringPool.BLANK)) {
22421                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
22422                    }
22423                    else {
22424                            bindArticleId = true;
22425    
22426                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
22427                    }
22428    
22429                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
22430    
22431                    if (orderByComparator != null) {
22432                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
22433    
22434                            if (orderByConditionFields.length > 0) {
22435                                    query.append(WHERE_AND);
22436                            }
22437    
22438                            for (int i = 0; i < orderByConditionFields.length; i++) {
22439                                    query.append(_ORDER_BY_ENTITY_ALIAS);
22440                                    query.append(orderByConditionFields[i]);
22441    
22442                                    if ((i + 1) < orderByConditionFields.length) {
22443                                            if (orderByComparator.isAscending() ^ previous) {
22444                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
22445                                            }
22446                                            else {
22447                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
22448                                            }
22449                                    }
22450                                    else {
22451                                            if (orderByComparator.isAscending() ^ previous) {
22452                                                    query.append(WHERE_GREATER_THAN);
22453                                            }
22454                                            else {
22455                                                    query.append(WHERE_LESSER_THAN);
22456                                            }
22457                                    }
22458                            }
22459    
22460                            query.append(ORDER_BY_CLAUSE);
22461    
22462                            String[] orderByFields = orderByComparator.getOrderByFields();
22463    
22464                            for (int i = 0; i < orderByFields.length; i++) {
22465                                    query.append(_ORDER_BY_ENTITY_ALIAS);
22466                                    query.append(orderByFields[i]);
22467    
22468                                    if ((i + 1) < orderByFields.length) {
22469                                            if (orderByComparator.isAscending() ^ previous) {
22470                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
22471                                            }
22472                                            else {
22473                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
22474                                            }
22475                                    }
22476                                    else {
22477                                            if (orderByComparator.isAscending() ^ previous) {
22478                                                    query.append(ORDER_BY_ASC);
22479                                            }
22480                                            else {
22481                                                    query.append(ORDER_BY_DESC);
22482                                            }
22483                                    }
22484                            }
22485                    }
22486                    else {
22487                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22488                    }
22489    
22490                    String sql = query.toString();
22491    
22492                    Query q = session.createQuery(sql);
22493    
22494                    q.setFirstResult(0);
22495                    q.setMaxResults(2);
22496    
22497                    QueryPos qPos = QueryPos.getInstance(q);
22498    
22499                    qPos.add(groupId);
22500    
22501                    if (bindArticleId) {
22502                            qPos.add(articleId);
22503                    }
22504    
22505                    qPos.add(status);
22506    
22507                    if (orderByComparator != null) {
22508                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
22509    
22510                            for (Object value : values) {
22511                                    qPos.add(value);
22512                            }
22513                    }
22514    
22515                    List<JournalArticle> list = q.list();
22516    
22517                    if (list.size() == 2) {
22518                            return list.get(1);
22519                    }
22520                    else {
22521                            return null;
22522                    }
22523            }
22524    
22525            /**
22526             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
22527             *
22528             * @param groupId the group ID
22529             * @param articleId the article ID
22530             * @param status the status
22531             * @return the matching journal articles that the user has permission to view
22532             * @throws SystemException if a system exception occurred
22533             */
22534            public List<JournalArticle> filterFindByG_A_ST(long groupId,
22535                    String articleId, int status) throws SystemException {
22536                    return filterFindByG_A_ST(groupId, articleId, status,
22537                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
22538            }
22539    
22540            /**
22541             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
22542             *
22543             * <p>
22544             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22545             * </p>
22546             *
22547             * @param groupId the group ID
22548             * @param articleId the article ID
22549             * @param status the status
22550             * @param start the lower bound of the range of journal articles
22551             * @param end the upper bound of the range of journal articles (not inclusive)
22552             * @return the range of matching journal articles that the user has permission to view
22553             * @throws SystemException if a system exception occurred
22554             */
22555            public List<JournalArticle> filterFindByG_A_ST(long groupId,
22556                    String articleId, int status, int start, int end)
22557                    throws SystemException {
22558                    return filterFindByG_A_ST(groupId, articleId, status, start, end, null);
22559            }
22560    
22561            /**
22562             * 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;.
22563             *
22564             * <p>
22565             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22566             * </p>
22567             *
22568             * @param groupId the group ID
22569             * @param articleId the article ID
22570             * @param status the status
22571             * @param start the lower bound of the range of journal articles
22572             * @param end the upper bound of the range of journal articles (not inclusive)
22573             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
22574             * @return the ordered range of matching journal articles that the user has permission to view
22575             * @throws SystemException if a system exception occurred
22576             */
22577            public List<JournalArticle> filterFindByG_A_ST(long groupId,
22578                    String articleId, int status, int start, int end,
22579                    OrderByComparator orderByComparator) throws SystemException {
22580                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22581                            return findByG_A_ST(groupId, articleId, status, start, end,
22582                                    orderByComparator);
22583                    }
22584    
22585                    StringBundler query = null;
22586    
22587                    if (orderByComparator != null) {
22588                            query = new StringBundler(5 +
22589                                            (orderByComparator.getOrderByFields().length * 3));
22590                    }
22591                    else {
22592                            query = new StringBundler(5);
22593                    }
22594    
22595                    if (getDB().isSupportsInlineDistinct()) {
22596                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
22597                    }
22598                    else {
22599                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
22600                    }
22601    
22602                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
22603    
22604                    boolean bindArticleId = false;
22605    
22606                    if (articleId == null) {
22607                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
22608                    }
22609                    else if (articleId.equals(StringPool.BLANK)) {
22610                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
22611                    }
22612                    else {
22613                            bindArticleId = true;
22614    
22615                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
22616                    }
22617    
22618                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
22619    
22620                    if (!getDB().isSupportsInlineDistinct()) {
22621                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
22622                    }
22623    
22624                    if (orderByComparator != null) {
22625                            if (getDB().isSupportsInlineDistinct()) {
22626                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
22627                                            orderByComparator);
22628                            }
22629                            else {
22630                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
22631                                            orderByComparator);
22632                            }
22633                    }
22634                    else {
22635                            if (getDB().isSupportsInlineDistinct()) {
22636                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22637                            }
22638                            else {
22639                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
22640                            }
22641                    }
22642    
22643                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22644                                    JournalArticle.class.getName(),
22645                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22646    
22647                    Session session = null;
22648    
22649                    try {
22650                            session = openSession();
22651    
22652                            SQLQuery q = session.createSQLQuery(sql);
22653    
22654                            if (getDB().isSupportsInlineDistinct()) {
22655                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
22656                            }
22657                            else {
22658                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
22659                            }
22660    
22661                            QueryPos qPos = QueryPos.getInstance(q);
22662    
22663                            qPos.add(groupId);
22664    
22665                            if (bindArticleId) {
22666                                    qPos.add(articleId);
22667                            }
22668    
22669                            qPos.add(status);
22670    
22671                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
22672                                    end);
22673                    }
22674                    catch (Exception e) {
22675                            throw processException(e);
22676                    }
22677                    finally {
22678                            closeSession(session);
22679                    }
22680            }
22681    
22682            /**
22683             * 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;.
22684             *
22685             * @param id the primary key of the current journal article
22686             * @param groupId the group ID
22687             * @param articleId the article ID
22688             * @param status the status
22689             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22690             * @return the previous, current, and next journal article
22691             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
22692             * @throws SystemException if a system exception occurred
22693             */
22694            public JournalArticle[] filterFindByG_A_ST_PrevAndNext(long id,
22695                    long groupId, String articleId, int status,
22696                    OrderByComparator orderByComparator)
22697                    throws NoSuchArticleException, SystemException {
22698                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22699                            return findByG_A_ST_PrevAndNext(id, groupId, articleId, status,
22700                                    orderByComparator);
22701                    }
22702    
22703                    JournalArticle journalArticle = findByPrimaryKey(id);
22704    
22705                    Session session = null;
22706    
22707                    try {
22708                            session = openSession();
22709    
22710                            JournalArticle[] array = new JournalArticleImpl[3];
22711    
22712                            array[0] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
22713                                            groupId, articleId, status, orderByComparator, true);
22714    
22715                            array[1] = journalArticle;
22716    
22717                            array[2] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
22718                                            groupId, articleId, status, orderByComparator, false);
22719    
22720                            return array;
22721                    }
22722                    catch (Exception e) {
22723                            throw processException(e);
22724                    }
22725                    finally {
22726                            closeSession(session);
22727                    }
22728            }
22729    
22730            protected JournalArticle filterGetByG_A_ST_PrevAndNext(Session session,
22731                    JournalArticle journalArticle, long groupId, String articleId,
22732                    int status, OrderByComparator orderByComparator, boolean previous) {
22733                    StringBundler query = null;
22734    
22735                    if (orderByComparator != null) {
22736                            query = new StringBundler(6 +
22737                                            (orderByComparator.getOrderByFields().length * 6));
22738                    }
22739                    else {
22740                            query = new StringBundler(3);
22741                    }
22742    
22743                    if (getDB().isSupportsInlineDistinct()) {
22744                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
22745                    }
22746                    else {
22747                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
22748                    }
22749    
22750                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
22751    
22752                    boolean bindArticleId = false;
22753    
22754                    if (articleId == null) {
22755                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
22756                    }
22757                    else if (articleId.equals(StringPool.BLANK)) {
22758                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
22759                    }
22760                    else {
22761                            bindArticleId = true;
22762    
22763                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
22764                    }
22765    
22766                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
22767    
22768                    if (!getDB().isSupportsInlineDistinct()) {
22769                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
22770                    }
22771    
22772                    if (orderByComparator != null) {
22773                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
22774    
22775                            if (orderByConditionFields.length > 0) {
22776                                    query.append(WHERE_AND);
22777                            }
22778    
22779                            for (int i = 0; i < orderByConditionFields.length; i++) {
22780                                    if (getDB().isSupportsInlineDistinct()) {
22781                                            query.append(_ORDER_BY_ENTITY_ALIAS);
22782                                    }
22783                                    else {
22784                                            query.append(_ORDER_BY_ENTITY_TABLE);
22785                                    }
22786    
22787                                    query.append(orderByConditionFields[i]);
22788    
22789                                    if ((i + 1) < orderByConditionFields.length) {
22790                                            if (orderByComparator.isAscending() ^ previous) {
22791                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
22792                                            }
22793                                            else {
22794                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
22795                                            }
22796                                    }
22797                                    else {
22798                                            if (orderByComparator.isAscending() ^ previous) {
22799                                                    query.append(WHERE_GREATER_THAN);
22800                                            }
22801                                            else {
22802                                                    query.append(WHERE_LESSER_THAN);
22803                                            }
22804                                    }
22805                            }
22806    
22807                            query.append(ORDER_BY_CLAUSE);
22808    
22809                            String[] orderByFields = orderByComparator.getOrderByFields();
22810    
22811                            for (int i = 0; i < orderByFields.length; i++) {
22812                                    if (getDB().isSupportsInlineDistinct()) {
22813                                            query.append(_ORDER_BY_ENTITY_ALIAS);
22814                                    }
22815                                    else {
22816                                            query.append(_ORDER_BY_ENTITY_TABLE);
22817                                    }
22818    
22819                                    query.append(orderByFields[i]);
22820    
22821                                    if ((i + 1) < orderByFields.length) {
22822                                            if (orderByComparator.isAscending() ^ previous) {
22823                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
22824                                            }
22825                                            else {
22826                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
22827                                            }
22828                                    }
22829                                    else {
22830                                            if (orderByComparator.isAscending() ^ previous) {
22831                                                    query.append(ORDER_BY_ASC);
22832                                            }
22833                                            else {
22834                                                    query.append(ORDER_BY_DESC);
22835                                            }
22836                                    }
22837                            }
22838                    }
22839                    else {
22840                            if (getDB().isSupportsInlineDistinct()) {
22841                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22842                            }
22843                            else {
22844                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
22845                            }
22846                    }
22847    
22848                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22849                                    JournalArticle.class.getName(),
22850                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22851    
22852                    SQLQuery q = session.createSQLQuery(sql);
22853    
22854                    q.setFirstResult(0);
22855                    q.setMaxResults(2);
22856    
22857                    if (getDB().isSupportsInlineDistinct()) {
22858                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
22859                    }
22860                    else {
22861                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
22862                    }
22863    
22864                    QueryPos qPos = QueryPos.getInstance(q);
22865    
22866                    qPos.add(groupId);
22867    
22868                    if (bindArticleId) {
22869                            qPos.add(articleId);
22870                    }
22871    
22872                    qPos.add(status);
22873    
22874                    if (orderByComparator != null) {
22875                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
22876    
22877                            for (Object value : values) {
22878                                    qPos.add(value);
22879                            }
22880                    }
22881    
22882                    List<JournalArticle> list = q.list();
22883    
22884                    if (list.size() == 2) {
22885                            return list.get(1);
22886                    }
22887                    else {
22888                            return null;
22889                    }
22890            }
22891    
22892            /**
22893             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
22894             *
22895             * @param groupId the group ID
22896             * @param articleId the article ID
22897             * @param statuses the statuses
22898             * @return the matching journal articles that the user has permission to view
22899             * @throws SystemException if a system exception occurred
22900             */
22901            public List<JournalArticle> filterFindByG_A_ST(long groupId,
22902                    String articleId, int[] statuses) throws SystemException {
22903                    return filterFindByG_A_ST(groupId, articleId, statuses,
22904                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
22905            }
22906    
22907            /**
22908             * 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;.
22909             *
22910             * <p>
22911             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22912             * </p>
22913             *
22914             * @param groupId the group ID
22915             * @param articleId the article ID
22916             * @param statuses the statuses
22917             * @param start the lower bound of the range of journal articles
22918             * @param end the upper bound of the range of journal articles (not inclusive)
22919             * @return the range of matching journal articles that the user has permission to view
22920             * @throws SystemException if a system exception occurred
22921             */
22922            public List<JournalArticle> filterFindByG_A_ST(long groupId,
22923                    String articleId, int[] statuses, int start, int end)
22924                    throws SystemException {
22925                    return filterFindByG_A_ST(groupId, articleId, statuses, start, end, null);
22926            }
22927    
22928            /**
22929             * 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;.
22930             *
22931             * <p>
22932             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22933             * </p>
22934             *
22935             * @param groupId the group ID
22936             * @param articleId the article ID
22937             * @param statuses the statuses
22938             * @param start the lower bound of the range of journal articles
22939             * @param end the upper bound of the range of journal articles (not inclusive)
22940             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
22941             * @return the ordered range of matching journal articles that the user has permission to view
22942             * @throws SystemException if a system exception occurred
22943             */
22944            public List<JournalArticle> filterFindByG_A_ST(long groupId,
22945                    String articleId, int[] statuses, int start, int end,
22946                    OrderByComparator orderByComparator) throws SystemException {
22947                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22948                            return findByG_A_ST(groupId, articleId, statuses, start, end,
22949                                    orderByComparator);
22950                    }
22951    
22952                    StringBundler query = new StringBundler();
22953    
22954                    if (getDB().isSupportsInlineDistinct()) {
22955                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
22956                    }
22957                    else {
22958                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
22959                    }
22960    
22961                    boolean conjunctionable = false;
22962    
22963                    if (conjunctionable) {
22964                            query.append(WHERE_AND);
22965                    }
22966    
22967                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
22968    
22969                    conjunctionable = true;
22970    
22971                    if (conjunctionable) {
22972                            query.append(WHERE_AND);
22973                    }
22974    
22975                    if (articleId == null) {
22976                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
22977                    }
22978                    else if (articleId.equals(StringPool.BLANK)) {
22979                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
22980                    }
22981                    else {
22982                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
22983                    }
22984    
22985                    conjunctionable = true;
22986    
22987                    if ((statuses == null) || (statuses.length > 0)) {
22988                            if (conjunctionable) {
22989                                    query.append(WHERE_AND);
22990                            }
22991    
22992                            query.append(StringPool.OPEN_PARENTHESIS);
22993    
22994                            for (int i = 0; i < statuses.length; i++) {
22995                                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
22996    
22997                                    if ((i + 1) < statuses.length) {
22998                                            query.append(WHERE_OR);
22999                                    }
23000                            }
23001    
23002                            query.append(StringPool.CLOSE_PARENTHESIS);
23003    
23004                            conjunctionable = true;
23005                    }
23006    
23007                    if (!getDB().isSupportsInlineDistinct()) {
23008                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
23009                    }
23010    
23011                    if (orderByComparator != null) {
23012                            if (getDB().isSupportsInlineDistinct()) {
23013                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
23014                                            orderByComparator);
23015                            }
23016                            else {
23017                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
23018                                            orderByComparator);
23019                            }
23020                    }
23021                    else {
23022                            if (getDB().isSupportsInlineDistinct()) {
23023                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23024                            }
23025                            else {
23026                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
23027                            }
23028                    }
23029    
23030                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23031                                    JournalArticle.class.getName(),
23032                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23033    
23034                    Session session = null;
23035    
23036                    try {
23037                            session = openSession();
23038    
23039                            SQLQuery q = session.createSQLQuery(sql);
23040    
23041                            if (getDB().isSupportsInlineDistinct()) {
23042                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
23043                            }
23044                            else {
23045                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
23046                            }
23047    
23048                            QueryPos qPos = QueryPos.getInstance(q);
23049    
23050                            qPos.add(groupId);
23051    
23052                            if (articleId != null) {
23053                                    qPos.add(articleId);
23054                            }
23055    
23056                            if (statuses != null) {
23057                                    qPos.add(statuses);
23058                            }
23059    
23060                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
23061                                    end);
23062                    }
23063                    catch (Exception e) {
23064                            throw processException(e);
23065                    }
23066                    finally {
23067                            closeSession(session);
23068                    }
23069            }
23070    
23071            /**
23072             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
23073             *
23074             * <p>
23075             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23076             * </p>
23077             *
23078             * @param groupId the group ID
23079             * @param articleId the article ID
23080             * @param statuses the statuses
23081             * @return the matching journal articles
23082             * @throws SystemException if a system exception occurred
23083             */
23084            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
23085                    int[] statuses) throws SystemException {
23086                    return findByG_A_ST(groupId, articleId, statuses, QueryUtil.ALL_POS,
23087                            QueryUtil.ALL_POS, null);
23088            }
23089    
23090            /**
23091             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
23092             *
23093             * <p>
23094             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23095             * </p>
23096             *
23097             * @param groupId the group ID
23098             * @param articleId the article ID
23099             * @param statuses the statuses
23100             * @param start the lower bound of the range of journal articles
23101             * @param end the upper bound of the range of journal articles (not inclusive)
23102             * @return the range of matching journal articles
23103             * @throws SystemException if a system exception occurred
23104             */
23105            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
23106                    int[] statuses, int start, int end) throws SystemException {
23107                    return findByG_A_ST(groupId, articleId, statuses, start, end, null);
23108            }
23109    
23110            /**
23111             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
23112             *
23113             * <p>
23114             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23115             * </p>
23116             *
23117             * @param groupId the group ID
23118             * @param articleId the article ID
23119             * @param statuses the statuses
23120             * @param start the lower bound of the range of journal articles
23121             * @param end the upper bound of the range of journal articles (not inclusive)
23122             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
23123             * @return the ordered range of matching journal articles
23124             * @throws SystemException if a system exception occurred
23125             */
23126            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
23127                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
23128                    throws SystemException {
23129                    if ((statuses != null) && (statuses.length == 1)) {
23130                            return findByG_A_ST(groupId, articleId, statuses[0], start, end,
23131                                    orderByComparator);
23132                    }
23133    
23134                    boolean pagination = true;
23135                    Object[] finderArgs = null;
23136    
23137                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
23138                                    (orderByComparator == null)) {
23139                            pagination = false;
23140                            finderArgs = new Object[] {
23141                                            groupId, articleId, StringUtil.merge(statuses)
23142                                    };
23143                    }
23144                    else {
23145                            finderArgs = new Object[] {
23146                                            groupId, articleId, StringUtil.merge(statuses),
23147                                            
23148                                            start, end, orderByComparator
23149                                    };
23150                    }
23151    
23152                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
23153                                    finderArgs, this);
23154    
23155                    if ((list != null) && !list.isEmpty()) {
23156                            for (JournalArticle journalArticle : list) {
23157                                    if ((groupId != journalArticle.getGroupId()) ||
23158                                                    !Validator.equals(articleId,
23159                                                            journalArticle.getArticleId()) ||
23160                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
23161                                            list = null;
23162    
23163                                            break;
23164                                    }
23165                            }
23166                    }
23167    
23168                    if (list == null) {
23169                            StringBundler query = new StringBundler();
23170    
23171                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
23172    
23173                            boolean conjunctionable = false;
23174    
23175                            if (conjunctionable) {
23176                                    query.append(WHERE_AND);
23177                            }
23178    
23179                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
23180    
23181                            conjunctionable = true;
23182    
23183                            if (conjunctionable) {
23184                                    query.append(WHERE_AND);
23185                            }
23186    
23187                            if (articleId == null) {
23188                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
23189                            }
23190                            else if (articleId.equals(StringPool.BLANK)) {
23191                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
23192                            }
23193                            else {
23194                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
23195                            }
23196    
23197                            conjunctionable = true;
23198    
23199                            if ((statuses == null) || (statuses.length > 0)) {
23200                                    if (conjunctionable) {
23201                                            query.append(WHERE_AND);
23202                                    }
23203    
23204                                    query.append(StringPool.OPEN_PARENTHESIS);
23205    
23206                                    for (int i = 0; i < statuses.length; i++) {
23207                                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
23208    
23209                                            if ((i + 1) < statuses.length) {
23210                                                    query.append(WHERE_OR);
23211                                            }
23212                                    }
23213    
23214                                    query.append(StringPool.CLOSE_PARENTHESIS);
23215    
23216                                    conjunctionable = true;
23217                            }
23218    
23219                            if (orderByComparator != null) {
23220                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
23221                                            orderByComparator);
23222                            }
23223                            else
23224                             if (pagination) {
23225                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23226                            }
23227    
23228                            String sql = query.toString();
23229    
23230                            Session session = null;
23231    
23232                            try {
23233                                    session = openSession();
23234    
23235                                    Query q = session.createQuery(sql);
23236    
23237                                    QueryPos qPos = QueryPos.getInstance(q);
23238    
23239                                    qPos.add(groupId);
23240    
23241                                    if (articleId != null) {
23242                                            qPos.add(articleId);
23243                                    }
23244    
23245                                    if (statuses != null) {
23246                                            qPos.add(statuses);
23247                                    }
23248    
23249                                    if (!pagination) {
23250                                            list = (List<JournalArticle>)QueryUtil.list(q,
23251                                                            getDialect(), start, end, false);
23252    
23253                                            Collections.sort(list);
23254    
23255                                            list = new UnmodifiableList<JournalArticle>(list);
23256                                    }
23257                                    else {
23258                                            list = (List<JournalArticle>)QueryUtil.list(q,
23259                                                            getDialect(), start, end);
23260                                    }
23261    
23262                                    cacheResult(list);
23263    
23264                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
23265                                            finderArgs, list);
23266                            }
23267                            catch (Exception e) {
23268                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
23269                                            finderArgs);
23270    
23271                                    throw processException(e);
23272                            }
23273                            finally {
23274                                    closeSession(session);
23275                            }
23276                    }
23277    
23278                    return list;
23279            }
23280    
23281            /**
23282             * Removes all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63; from the database.
23283             *
23284             * @param groupId the group ID
23285             * @param articleId the article ID
23286             * @param status the status
23287             * @throws SystemException if a system exception occurred
23288             */
23289            public void removeByG_A_ST(long groupId, String articleId, int status)
23290                    throws SystemException {
23291                    for (JournalArticle journalArticle : findByG_A_ST(groupId, articleId,
23292                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
23293                            remove(journalArticle);
23294                    }
23295            }
23296    
23297            /**
23298             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
23299             *
23300             * @param groupId the group ID
23301             * @param articleId the article ID
23302             * @param status the status
23303             * @return the number of matching journal articles
23304             * @throws SystemException if a system exception occurred
23305             */
23306            public int countByG_A_ST(long groupId, String articleId, int status)
23307                    throws SystemException {
23308                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A_ST;
23309    
23310                    Object[] finderArgs = new Object[] { groupId, articleId, status };
23311    
23312                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
23313                                    this);
23314    
23315                    if (count == null) {
23316                            StringBundler query = new StringBundler(4);
23317    
23318                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
23319    
23320                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
23321    
23322                            boolean bindArticleId = false;
23323    
23324                            if (articleId == null) {
23325                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
23326                            }
23327                            else if (articleId.equals(StringPool.BLANK)) {
23328                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
23329                            }
23330                            else {
23331                                    bindArticleId = true;
23332    
23333                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
23334                            }
23335    
23336                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
23337    
23338                            String sql = query.toString();
23339    
23340                            Session session = null;
23341    
23342                            try {
23343                                    session = openSession();
23344    
23345                                    Query q = session.createQuery(sql);
23346    
23347                                    QueryPos qPos = QueryPos.getInstance(q);
23348    
23349                                    qPos.add(groupId);
23350    
23351                                    if (bindArticleId) {
23352                                            qPos.add(articleId);
23353                                    }
23354    
23355                                    qPos.add(status);
23356    
23357                                    count = (Long)q.uniqueResult();
23358    
23359                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
23360                            }
23361                            catch (Exception e) {
23362                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
23363    
23364                                    throw processException(e);
23365                            }
23366                            finally {
23367                                    closeSession(session);
23368                            }
23369                    }
23370    
23371                    return count.intValue();
23372            }
23373    
23374            /**
23375             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
23376             *
23377             * @param groupId the group ID
23378             * @param articleId the article ID
23379             * @param statuses the statuses
23380             * @return the number of matching journal articles
23381             * @throws SystemException if a system exception occurred
23382             */
23383            public int countByG_A_ST(long groupId, String articleId, int[] statuses)
23384                    throws SystemException {
23385                    Object[] finderArgs = new Object[] {
23386                                    groupId, articleId, StringUtil.merge(statuses)
23387                            };
23388    
23389                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
23390                                    finderArgs, this);
23391    
23392                    if (count == null) {
23393                            StringBundler query = new StringBundler();
23394    
23395                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
23396    
23397                            boolean conjunctionable = false;
23398    
23399                            if (conjunctionable) {
23400                                    query.append(WHERE_AND);
23401                            }
23402    
23403                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
23404    
23405                            conjunctionable = true;
23406    
23407                            if (conjunctionable) {
23408                                    query.append(WHERE_AND);
23409                            }
23410    
23411                            if (articleId == null) {
23412                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
23413                            }
23414                            else if (articleId.equals(StringPool.BLANK)) {
23415                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
23416                            }
23417                            else {
23418                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
23419                            }
23420    
23421                            conjunctionable = true;
23422    
23423                            if ((statuses == null) || (statuses.length > 0)) {
23424                                    if (conjunctionable) {
23425                                            query.append(WHERE_AND);
23426                                    }
23427    
23428                                    query.append(StringPool.OPEN_PARENTHESIS);
23429    
23430                                    for (int i = 0; i < statuses.length; i++) {
23431                                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
23432    
23433                                            if ((i + 1) < statuses.length) {
23434                                                    query.append(WHERE_OR);
23435                                            }
23436                                    }
23437    
23438                                    query.append(StringPool.CLOSE_PARENTHESIS);
23439    
23440                                    conjunctionable = true;
23441                            }
23442    
23443                            String sql = query.toString();
23444    
23445                            Session session = null;
23446    
23447                            try {
23448                                    session = openSession();
23449    
23450                                    Query q = session.createQuery(sql);
23451    
23452                                    QueryPos qPos = QueryPos.getInstance(q);
23453    
23454                                    qPos.add(groupId);
23455    
23456                                    if (articleId != null) {
23457                                            qPos.add(articleId);
23458                                    }
23459    
23460                                    if (statuses != null) {
23461                                            qPos.add(statuses);
23462                                    }
23463    
23464                                    count = (Long)q.uniqueResult();
23465    
23466                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
23467                                            finderArgs, count);
23468                            }
23469                            catch (Exception e) {
23470                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
23471                                            finderArgs);
23472    
23473                                    throw processException(e);
23474                            }
23475                            finally {
23476                                    closeSession(session);
23477                            }
23478                    }
23479    
23480                    return count.intValue();
23481            }
23482    
23483            /**
23484             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
23485             *
23486             * @param groupId the group ID
23487             * @param articleId the article ID
23488             * @param status the status
23489             * @return the number of matching journal articles that the user has permission to view
23490             * @throws SystemException if a system exception occurred
23491             */
23492            public int filterCountByG_A_ST(long groupId, String articleId, int status)
23493                    throws SystemException {
23494                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23495                            return countByG_A_ST(groupId, articleId, status);
23496                    }
23497    
23498                    StringBundler query = new StringBundler(4);
23499    
23500                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
23501    
23502                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
23503    
23504                    boolean bindArticleId = false;
23505    
23506                    if (articleId == null) {
23507                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
23508                    }
23509                    else if (articleId.equals(StringPool.BLANK)) {
23510                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
23511                    }
23512                    else {
23513                            bindArticleId = true;
23514    
23515                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
23516                    }
23517    
23518                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
23519    
23520                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23521                                    JournalArticle.class.getName(),
23522                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23523    
23524                    Session session = null;
23525    
23526                    try {
23527                            session = openSession();
23528    
23529                            SQLQuery q = session.createSQLQuery(sql);
23530    
23531                            q.addScalar(COUNT_COLUMN_NAME,
23532                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
23533    
23534                            QueryPos qPos = QueryPos.getInstance(q);
23535    
23536                            qPos.add(groupId);
23537    
23538                            if (bindArticleId) {
23539                                    qPos.add(articleId);
23540                            }
23541    
23542                            qPos.add(status);
23543    
23544                            Long count = (Long)q.uniqueResult();
23545    
23546                            return count.intValue();
23547                    }
23548                    catch (Exception e) {
23549                            throw processException(e);
23550                    }
23551                    finally {
23552                            closeSession(session);
23553                    }
23554            }
23555    
23556            /**
23557             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
23558             *
23559             * @param groupId the group ID
23560             * @param articleId the article ID
23561             * @param statuses the statuses
23562             * @return the number of matching journal articles that the user has permission to view
23563             * @throws SystemException if a system exception occurred
23564             */
23565            public int filterCountByG_A_ST(long groupId, String articleId,
23566                    int[] statuses) throws SystemException {
23567                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23568                            return countByG_A_ST(groupId, articleId, statuses);
23569                    }
23570    
23571                    StringBundler query = new StringBundler();
23572    
23573                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
23574    
23575                    boolean conjunctionable = false;
23576    
23577                    if (conjunctionable) {
23578                            query.append(WHERE_AND);
23579                    }
23580    
23581                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
23582    
23583                    conjunctionable = true;
23584    
23585                    if (conjunctionable) {
23586                            query.append(WHERE_AND);
23587                    }
23588    
23589                    if (articleId == null) {
23590                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
23591                    }
23592                    else if (articleId.equals(StringPool.BLANK)) {
23593                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
23594                    }
23595                    else {
23596                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
23597                    }
23598    
23599                    conjunctionable = true;
23600    
23601                    if ((statuses == null) || (statuses.length > 0)) {
23602                            if (conjunctionable) {
23603                                    query.append(WHERE_AND);
23604                            }
23605    
23606                            query.append(StringPool.OPEN_PARENTHESIS);
23607    
23608                            for (int i = 0; i < statuses.length; i++) {
23609                                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
23610    
23611                                    if ((i + 1) < statuses.length) {
23612                                            query.append(WHERE_OR);
23613                                    }
23614                            }
23615    
23616                            query.append(StringPool.CLOSE_PARENTHESIS);
23617    
23618                            conjunctionable = true;
23619                    }
23620    
23621                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23622                                    JournalArticle.class.getName(),
23623                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23624    
23625                    Session session = null;
23626    
23627                    try {
23628                            session = openSession();
23629    
23630                            SQLQuery q = session.createSQLQuery(sql);
23631    
23632                            q.addScalar(COUNT_COLUMN_NAME,
23633                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
23634    
23635                            QueryPos qPos = QueryPos.getInstance(q);
23636    
23637                            qPos.add(groupId);
23638    
23639                            if (articleId != null) {
23640                                    qPos.add(articleId);
23641                            }
23642    
23643                            if (statuses != null) {
23644                                    qPos.add(statuses);
23645                            }
23646    
23647                            Long count = (Long)q.uniqueResult();
23648    
23649                            return count.intValue();
23650                    }
23651                    catch (Exception e) {
23652                            throw processException(e);
23653                    }
23654                    finally {
23655                            closeSession(session);
23656                    }
23657            }
23658    
23659            private static final String _FINDER_COLUMN_G_A_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
23660            private static final String _FINDER_COLUMN_G_A_ST_GROUPID_5 = "(" +
23661                    removeConjunction(_FINDER_COLUMN_G_A_ST_GROUPID_2) + ")";
23662            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
23663            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
23664            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '') AND ";
23665            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_4 = "(" +
23666                    removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_1) + ")";
23667            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_5 = "(" +
23668                    removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_2) + ")";
23669            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_6 = "(" +
23670                    removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_3) + ")";
23671            private static final String _FINDER_COLUMN_G_A_ST_STATUS_2 = "journalArticle.status = ?";
23672            private static final String _FINDER_COLUMN_G_A_ST_STATUS_5 = "(" +
23673                    removeConjunction(_FINDER_COLUMN_G_A_ST_STATUS_2) + ")";
23674            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23675                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
23676                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
23677                            "findByG_UT_ST",
23678                            new String[] {
23679                                    Long.class.getName(), String.class.getName(),
23680                                    Integer.class.getName(),
23681                                    
23682                            Integer.class.getName(), Integer.class.getName(),
23683                                    OrderByComparator.class.getName()
23684                            });
23685            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST =
23686                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23687                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
23688                            JournalArticleImpl.class,
23689                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_UT_ST",
23690                            new String[] {
23691                                    Long.class.getName(), String.class.getName(),
23692                                    Integer.class.getName()
23693                            },
23694                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
23695                            JournalArticleModelImpl.URLTITLE_COLUMN_BITMASK |
23696                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
23697                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
23698                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
23699            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23700                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
23701                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT_ST",
23702                            new String[] {
23703                                    Long.class.getName(), String.class.getName(),
23704                                    Integer.class.getName()
23705                            });
23706    
23707            /**
23708             * Returns all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
23709             *
23710             * @param groupId the group ID
23711             * @param urlTitle the url title
23712             * @param status the status
23713             * @return the matching journal articles
23714             * @throws SystemException if a system exception occurred
23715             */
23716            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
23717                    int status) throws SystemException {
23718                    return findByG_UT_ST(groupId, urlTitle, status, QueryUtil.ALL_POS,
23719                            QueryUtil.ALL_POS, null);
23720            }
23721    
23722            /**
23723             * Returns a range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
23724             *
23725             * <p>
23726             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23727             * </p>
23728             *
23729             * @param groupId the group ID
23730             * @param urlTitle the url title
23731             * @param status the status
23732             * @param start the lower bound of the range of journal articles
23733             * @param end the upper bound of the range of journal articles (not inclusive)
23734             * @return the range of matching journal articles
23735             * @throws SystemException if a system exception occurred
23736             */
23737            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
23738                    int status, int start, int end) throws SystemException {
23739                    return findByG_UT_ST(groupId, urlTitle, status, start, end, null);
23740            }
23741    
23742            /**
23743             * Returns an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
23744             *
23745             * <p>
23746             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23747             * </p>
23748             *
23749             * @param groupId the group ID
23750             * @param urlTitle the url title
23751             * @param status the status
23752             * @param start the lower bound of the range of journal articles
23753             * @param end the upper bound of the range of journal articles (not inclusive)
23754             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
23755             * @return the ordered range of matching journal articles
23756             * @throws SystemException if a system exception occurred
23757             */
23758            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
23759                    int status, int start, int end, OrderByComparator orderByComparator)
23760                    throws SystemException {
23761                    boolean pagination = true;
23762                    FinderPath finderPath = null;
23763                    Object[] finderArgs = null;
23764    
23765                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
23766                                    (orderByComparator == null)) {
23767                            pagination = false;
23768                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST;
23769                            finderArgs = new Object[] { groupId, urlTitle, status };
23770                    }
23771                    else {
23772                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT_ST;
23773                            finderArgs = new Object[] {
23774                                            groupId, urlTitle, status,
23775                                            
23776                                            start, end, orderByComparator
23777                                    };
23778                    }
23779    
23780                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
23781                                    finderArgs, this);
23782    
23783                    if ((list != null) && !list.isEmpty()) {
23784                            for (JournalArticle journalArticle : list) {
23785                                    if ((groupId != journalArticle.getGroupId()) ||
23786                                                    !Validator.equals(urlTitle, journalArticle.getUrlTitle()) ||
23787                                                    (status != journalArticle.getStatus())) {
23788                                            list = null;
23789    
23790                                            break;
23791                                    }
23792                            }
23793                    }
23794    
23795                    if (list == null) {
23796                            StringBundler query = null;
23797    
23798                            if (orderByComparator != null) {
23799                                    query = new StringBundler(5 +
23800                                                    (orderByComparator.getOrderByFields().length * 3));
23801                            }
23802                            else {
23803                                    query = new StringBundler(5);
23804                            }
23805    
23806                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
23807    
23808                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
23809    
23810                            boolean bindUrlTitle = false;
23811    
23812                            if (urlTitle == null) {
23813                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
23814                            }
23815                            else if (urlTitle.equals(StringPool.BLANK)) {
23816                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
23817                            }
23818                            else {
23819                                    bindUrlTitle = true;
23820    
23821                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
23822                            }
23823    
23824                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
23825    
23826                            if (orderByComparator != null) {
23827                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
23828                                            orderByComparator);
23829                            }
23830                            else
23831                             if (pagination) {
23832                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23833                            }
23834    
23835                            String sql = query.toString();
23836    
23837                            Session session = null;
23838    
23839                            try {
23840                                    session = openSession();
23841    
23842                                    Query q = session.createQuery(sql);
23843    
23844                                    QueryPos qPos = QueryPos.getInstance(q);
23845    
23846                                    qPos.add(groupId);
23847    
23848                                    if (bindUrlTitle) {
23849                                            qPos.add(urlTitle);
23850                                    }
23851    
23852                                    qPos.add(status);
23853    
23854                                    if (!pagination) {
23855                                            list = (List<JournalArticle>)QueryUtil.list(q,
23856                                                            getDialect(), start, end, false);
23857    
23858                                            Collections.sort(list);
23859    
23860                                            list = new UnmodifiableList<JournalArticle>(list);
23861                                    }
23862                                    else {
23863                                            list = (List<JournalArticle>)QueryUtil.list(q,
23864                                                            getDialect(), start, end);
23865                                    }
23866    
23867                                    cacheResult(list);
23868    
23869                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
23870                            }
23871                            catch (Exception e) {
23872                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
23873    
23874                                    throw processException(e);
23875                            }
23876                            finally {
23877                                    closeSession(session);
23878                            }
23879                    }
23880    
23881                    return list;
23882            }
23883    
23884            /**
23885             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
23886             *
23887             * @param groupId the group ID
23888             * @param urlTitle the url title
23889             * @param status the status
23890             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23891             * @return the first matching journal article
23892             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
23893             * @throws SystemException if a system exception occurred
23894             */
23895            public JournalArticle findByG_UT_ST_First(long groupId, String urlTitle,
23896                    int status, OrderByComparator orderByComparator)
23897                    throws NoSuchArticleException, SystemException {
23898                    JournalArticle journalArticle = fetchByG_UT_ST_First(groupId, urlTitle,
23899                                    status, orderByComparator);
23900    
23901                    if (journalArticle != null) {
23902                            return journalArticle;
23903                    }
23904    
23905                    StringBundler msg = new StringBundler(8);
23906    
23907                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
23908    
23909                    msg.append("groupId=");
23910                    msg.append(groupId);
23911    
23912                    msg.append(", urlTitle=");
23913                    msg.append(urlTitle);
23914    
23915                    msg.append(", status=");
23916                    msg.append(status);
23917    
23918                    msg.append(StringPool.CLOSE_CURLY_BRACE);
23919    
23920                    throw new NoSuchArticleException(msg.toString());
23921            }
23922    
23923            /**
23924             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
23925             *
23926             * @param groupId the group ID
23927             * @param urlTitle the url title
23928             * @param status the status
23929             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23930             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
23931             * @throws SystemException if a system exception occurred
23932             */
23933            public JournalArticle fetchByG_UT_ST_First(long groupId, String urlTitle,
23934                    int status, OrderByComparator orderByComparator)
23935                    throws SystemException {
23936                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status, 0,
23937                                    1, orderByComparator);
23938    
23939                    if (!list.isEmpty()) {
23940                            return list.get(0);
23941                    }
23942    
23943                    return null;
23944            }
23945    
23946            /**
23947             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
23948             *
23949             * @param groupId the group ID
23950             * @param urlTitle the url title
23951             * @param status the status
23952             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23953             * @return the last matching journal article
23954             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
23955             * @throws SystemException if a system exception occurred
23956             */
23957            public JournalArticle findByG_UT_ST_Last(long groupId, String urlTitle,
23958                    int status, OrderByComparator orderByComparator)
23959                    throws NoSuchArticleException, SystemException {
23960                    JournalArticle journalArticle = fetchByG_UT_ST_Last(groupId, urlTitle,
23961                                    status, orderByComparator);
23962    
23963                    if (journalArticle != null) {
23964                            return journalArticle;
23965                    }
23966    
23967                    StringBundler msg = new StringBundler(8);
23968    
23969                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
23970    
23971                    msg.append("groupId=");
23972                    msg.append(groupId);
23973    
23974                    msg.append(", urlTitle=");
23975                    msg.append(urlTitle);
23976    
23977                    msg.append(", status=");
23978                    msg.append(status);
23979    
23980                    msg.append(StringPool.CLOSE_CURLY_BRACE);
23981    
23982                    throw new NoSuchArticleException(msg.toString());
23983            }
23984    
23985            /**
23986             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
23987             *
23988             * @param groupId the group ID
23989             * @param urlTitle the url title
23990             * @param status the status
23991             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23992             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
23993             * @throws SystemException if a system exception occurred
23994             */
23995            public JournalArticle fetchByG_UT_ST_Last(long groupId, String urlTitle,
23996                    int status, OrderByComparator orderByComparator)
23997                    throws SystemException {
23998                    int count = countByG_UT_ST(groupId, urlTitle, status);
23999    
24000                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status,
24001                                    count - 1, count, orderByComparator);
24002    
24003                    if (!list.isEmpty()) {
24004                            return list.get(0);
24005                    }
24006    
24007                    return null;
24008            }
24009    
24010            /**
24011             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
24012             *
24013             * @param id the primary key of the current journal article
24014             * @param groupId the group ID
24015             * @param urlTitle the url title
24016             * @param status the status
24017             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24018             * @return the previous, current, and next journal article
24019             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
24020             * @throws SystemException if a system exception occurred
24021             */
24022            public JournalArticle[] findByG_UT_ST_PrevAndNext(long id, long groupId,
24023                    String urlTitle, int status, OrderByComparator orderByComparator)
24024                    throws NoSuchArticleException, SystemException {
24025                    JournalArticle journalArticle = findByPrimaryKey(id);
24026    
24027                    Session session = null;
24028    
24029                    try {
24030                            session = openSession();
24031    
24032                            JournalArticle[] array = new JournalArticleImpl[3];
24033    
24034                            array[0] = getByG_UT_ST_PrevAndNext(session, journalArticle,
24035                                            groupId, urlTitle, status, orderByComparator, true);
24036    
24037                            array[1] = journalArticle;
24038    
24039                            array[2] = getByG_UT_ST_PrevAndNext(session, journalArticle,
24040                                            groupId, urlTitle, status, orderByComparator, false);
24041    
24042                            return array;
24043                    }
24044                    catch (Exception e) {
24045                            throw processException(e);
24046                    }
24047                    finally {
24048                            closeSession(session);
24049                    }
24050            }
24051    
24052            protected JournalArticle getByG_UT_ST_PrevAndNext(Session session,
24053                    JournalArticle journalArticle, long groupId, String urlTitle,
24054                    int status, OrderByComparator orderByComparator, boolean previous) {
24055                    StringBundler query = null;
24056    
24057                    if (orderByComparator != null) {
24058                            query = new StringBundler(6 +
24059                                            (orderByComparator.getOrderByFields().length * 6));
24060                    }
24061                    else {
24062                            query = new StringBundler(3);
24063                    }
24064    
24065                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
24066    
24067                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
24068    
24069                    boolean bindUrlTitle = false;
24070    
24071                    if (urlTitle == null) {
24072                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
24073                    }
24074                    else if (urlTitle.equals(StringPool.BLANK)) {
24075                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
24076                    }
24077                    else {
24078                            bindUrlTitle = true;
24079    
24080                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
24081                    }
24082    
24083                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
24084    
24085                    if (orderByComparator != null) {
24086                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
24087    
24088                            if (orderByConditionFields.length > 0) {
24089                                    query.append(WHERE_AND);
24090                            }
24091    
24092                            for (int i = 0; i < orderByConditionFields.length; i++) {
24093                                    query.append(_ORDER_BY_ENTITY_ALIAS);
24094                                    query.append(orderByConditionFields[i]);
24095    
24096                                    if ((i + 1) < orderByConditionFields.length) {
24097                                            if (orderByComparator.isAscending() ^ previous) {
24098                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
24099                                            }
24100                                            else {
24101                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
24102                                            }
24103                                    }
24104                                    else {
24105                                            if (orderByComparator.isAscending() ^ previous) {
24106                                                    query.append(WHERE_GREATER_THAN);
24107                                            }
24108                                            else {
24109                                                    query.append(WHERE_LESSER_THAN);
24110                                            }
24111                                    }
24112                            }
24113    
24114                            query.append(ORDER_BY_CLAUSE);
24115    
24116                            String[] orderByFields = orderByComparator.getOrderByFields();
24117    
24118                            for (int i = 0; i < orderByFields.length; i++) {
24119                                    query.append(_ORDER_BY_ENTITY_ALIAS);
24120                                    query.append(orderByFields[i]);
24121    
24122                                    if ((i + 1) < orderByFields.length) {
24123                                            if (orderByComparator.isAscending() ^ previous) {
24124                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
24125                                            }
24126                                            else {
24127                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
24128                                            }
24129                                    }
24130                                    else {
24131                                            if (orderByComparator.isAscending() ^ previous) {
24132                                                    query.append(ORDER_BY_ASC);
24133                                            }
24134                                            else {
24135                                                    query.append(ORDER_BY_DESC);
24136                                            }
24137                                    }
24138                            }
24139                    }
24140                    else {
24141                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
24142                    }
24143    
24144                    String sql = query.toString();
24145    
24146                    Query q = session.createQuery(sql);
24147    
24148                    q.setFirstResult(0);
24149                    q.setMaxResults(2);
24150    
24151                    QueryPos qPos = QueryPos.getInstance(q);
24152    
24153                    qPos.add(groupId);
24154    
24155                    if (bindUrlTitle) {
24156                            qPos.add(urlTitle);
24157                    }
24158    
24159                    qPos.add(status);
24160    
24161                    if (orderByComparator != null) {
24162                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
24163    
24164                            for (Object value : values) {
24165                                    qPos.add(value);
24166                            }
24167                    }
24168    
24169                    List<JournalArticle> list = q.list();
24170    
24171                    if (list.size() == 2) {
24172                            return list.get(1);
24173                    }
24174                    else {
24175                            return null;
24176                    }
24177            }
24178    
24179            /**
24180             * Returns all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
24181             *
24182             * @param groupId the group ID
24183             * @param urlTitle the url title
24184             * @param status the status
24185             * @return the matching journal articles that the user has permission to view
24186             * @throws SystemException if a system exception occurred
24187             */
24188            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
24189                    String urlTitle, int status) throws SystemException {
24190                    return filterFindByG_UT_ST(groupId, urlTitle, status,
24191                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
24192            }
24193    
24194            /**
24195             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
24196             *
24197             * <p>
24198             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
24199             * </p>
24200             *
24201             * @param groupId the group ID
24202             * @param urlTitle the url title
24203             * @param status the status
24204             * @param start the lower bound of the range of journal articles
24205             * @param end the upper bound of the range of journal articles (not inclusive)
24206             * @return the range of matching journal articles that the user has permission to view
24207             * @throws SystemException if a system exception occurred
24208             */
24209            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
24210                    String urlTitle, int status, int start, int end)
24211                    throws SystemException {
24212                    return filterFindByG_UT_ST(groupId, urlTitle, status, start, end, null);
24213            }
24214    
24215            /**
24216             * 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;.
24217             *
24218             * <p>
24219             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
24220             * </p>
24221             *
24222             * @param groupId the group ID
24223             * @param urlTitle the url title
24224             * @param status the status
24225             * @param start the lower bound of the range of journal articles
24226             * @param end the upper bound of the range of journal articles (not inclusive)
24227             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
24228             * @return the ordered range of matching journal articles that the user has permission to view
24229             * @throws SystemException if a system exception occurred
24230             */
24231            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
24232                    String urlTitle, int status, int start, int end,
24233                    OrderByComparator orderByComparator) throws SystemException {
24234                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
24235                            return findByG_UT_ST(groupId, urlTitle, status, start, end,
24236                                    orderByComparator);
24237                    }
24238    
24239                    StringBundler query = null;
24240    
24241                    if (orderByComparator != null) {
24242                            query = new StringBundler(5 +
24243                                            (orderByComparator.getOrderByFields().length * 3));
24244                    }
24245                    else {
24246                            query = new StringBundler(5);
24247                    }
24248    
24249                    if (getDB().isSupportsInlineDistinct()) {
24250                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
24251                    }
24252                    else {
24253                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
24254                    }
24255    
24256                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
24257    
24258                    boolean bindUrlTitle = false;
24259    
24260                    if (urlTitle == null) {
24261                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
24262                    }
24263                    else if (urlTitle.equals(StringPool.BLANK)) {
24264                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
24265                    }
24266                    else {
24267                            bindUrlTitle = true;
24268    
24269                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
24270                    }
24271    
24272                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
24273    
24274                    if (!getDB().isSupportsInlineDistinct()) {
24275                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
24276                    }
24277    
24278                    if (orderByComparator != null) {
24279                            if (getDB().isSupportsInlineDistinct()) {
24280                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
24281                                            orderByComparator);
24282                            }
24283                            else {
24284                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
24285                                            orderByComparator);
24286                            }
24287                    }
24288                    else {
24289                            if (getDB().isSupportsInlineDistinct()) {
24290                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
24291                            }
24292                            else {
24293                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
24294                            }
24295                    }
24296    
24297                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
24298                                    JournalArticle.class.getName(),
24299                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
24300    
24301                    Session session = null;
24302    
24303                    try {
24304                            session = openSession();
24305    
24306                            SQLQuery q = session.createSQLQuery(sql);
24307    
24308                            if (getDB().isSupportsInlineDistinct()) {
24309                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
24310                            }
24311                            else {
24312                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
24313                            }
24314    
24315                            QueryPos qPos = QueryPos.getInstance(q);
24316    
24317                            qPos.add(groupId);
24318    
24319                            if (bindUrlTitle) {
24320                                    qPos.add(urlTitle);
24321                            }
24322    
24323                            qPos.add(status);
24324    
24325                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
24326                                    end);
24327                    }
24328                    catch (Exception e) {
24329                            throw processException(e);
24330                    }
24331                    finally {
24332                            closeSession(session);
24333                    }
24334            }
24335    
24336            /**
24337             * 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;.
24338             *
24339             * @param id the primary key of the current journal article
24340             * @param groupId the group ID
24341             * @param urlTitle the url title
24342             * @param status the status
24343             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24344             * @return the previous, current, and next journal article
24345             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
24346             * @throws SystemException if a system exception occurred
24347             */
24348            public JournalArticle[] filterFindByG_UT_ST_PrevAndNext(long id,
24349                    long groupId, String urlTitle, int status,
24350                    OrderByComparator orderByComparator)
24351                    throws NoSuchArticleException, SystemException {
24352                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
24353                            return findByG_UT_ST_PrevAndNext(id, groupId, urlTitle, status,
24354                                    orderByComparator);
24355                    }
24356    
24357                    JournalArticle journalArticle = findByPrimaryKey(id);
24358    
24359                    Session session = null;
24360    
24361                    try {
24362                            session = openSession();
24363    
24364                            JournalArticle[] array = new JournalArticleImpl[3];
24365    
24366                            array[0] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
24367                                            groupId, urlTitle, status, orderByComparator, true);
24368    
24369                            array[1] = journalArticle;
24370    
24371                            array[2] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
24372                                            groupId, urlTitle, status, orderByComparator, false);
24373    
24374                            return array;
24375                    }
24376                    catch (Exception e) {
24377                            throw processException(e);
24378                    }
24379                    finally {
24380                            closeSession(session);
24381                    }
24382            }
24383    
24384            protected JournalArticle filterGetByG_UT_ST_PrevAndNext(Session session,
24385                    JournalArticle journalArticle, long groupId, String urlTitle,
24386                    int status, OrderByComparator orderByComparator, boolean previous) {
24387                    StringBundler query = null;
24388    
24389                    if (orderByComparator != null) {
24390                            query = new StringBundler(6 +
24391                                            (orderByComparator.getOrderByFields().length * 6));
24392                    }
24393                    else {
24394                            query = new StringBundler(3);
24395                    }
24396    
24397                    if (getDB().isSupportsInlineDistinct()) {
24398                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
24399                    }
24400                    else {
24401                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
24402                    }
24403    
24404                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
24405    
24406                    boolean bindUrlTitle = false;
24407    
24408                    if (urlTitle == null) {
24409                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
24410                    }
24411                    else if (urlTitle.equals(StringPool.BLANK)) {
24412                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
24413                    }
24414                    else {
24415                            bindUrlTitle = true;
24416    
24417                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
24418                    }
24419    
24420                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
24421    
24422                    if (!getDB().isSupportsInlineDistinct()) {
24423                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
24424                    }
24425    
24426                    if (orderByComparator != null) {
24427                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
24428    
24429                            if (orderByConditionFields.length > 0) {
24430                                    query.append(WHERE_AND);
24431                            }
24432    
24433                            for (int i = 0; i < orderByConditionFields.length; i++) {
24434                                    if (getDB().isSupportsInlineDistinct()) {
24435                                            query.append(_ORDER_BY_ENTITY_ALIAS);
24436                                    }
24437                                    else {
24438                                            query.append(_ORDER_BY_ENTITY_TABLE);
24439                                    }
24440    
24441                                    query.append(orderByConditionFields[i]);
24442    
24443                                    if ((i + 1) < orderByConditionFields.length) {
24444                                            if (orderByComparator.isAscending() ^ previous) {
24445                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
24446                                            }
24447                                            else {
24448                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
24449                                            }
24450                                    }
24451                                    else {
24452                                            if (orderByComparator.isAscending() ^ previous) {
24453                                                    query.append(WHERE_GREATER_THAN);
24454                                            }
24455                                            else {
24456                                                    query.append(WHERE_LESSER_THAN);
24457                                            }
24458                                    }
24459                            }
24460    
24461                            query.append(ORDER_BY_CLAUSE);
24462    
24463                            String[] orderByFields = orderByComparator.getOrderByFields();
24464    
24465                            for (int i = 0; i < orderByFields.length; i++) {
24466                                    if (getDB().isSupportsInlineDistinct()) {
24467                                            query.append(_ORDER_BY_ENTITY_ALIAS);
24468                                    }
24469                                    else {
24470                                            query.append(_ORDER_BY_ENTITY_TABLE);
24471                                    }
24472    
24473                                    query.append(orderByFields[i]);
24474    
24475                                    if ((i + 1) < orderByFields.length) {
24476                                            if (orderByComparator.isAscending() ^ previous) {
24477                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
24478                                            }
24479                                            else {
24480                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
24481                                            }
24482                                    }
24483                                    else {
24484                                            if (orderByComparator.isAscending() ^ previous) {
24485                                                    query.append(ORDER_BY_ASC);
24486                                            }
24487                                            else {
24488                                                    query.append(ORDER_BY_DESC);
24489                                            }
24490                                    }
24491                            }
24492                    }
24493                    else {
24494                            if (getDB().isSupportsInlineDistinct()) {
24495                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
24496                            }
24497                            else {
24498                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
24499                            }
24500                    }
24501    
24502                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
24503                                    JournalArticle.class.getName(),
24504                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
24505    
24506                    SQLQuery q = session.createSQLQuery(sql);
24507    
24508                    q.setFirstResult(0);
24509                    q.setMaxResults(2);
24510    
24511                    if (getDB().isSupportsInlineDistinct()) {
24512                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
24513                    }
24514                    else {
24515                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
24516                    }
24517    
24518                    QueryPos qPos = QueryPos.getInstance(q);
24519    
24520                    qPos.add(groupId);
24521    
24522                    if (bindUrlTitle) {
24523                            qPos.add(urlTitle);
24524                    }
24525    
24526                    qPos.add(status);
24527    
24528                    if (orderByComparator != null) {
24529                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
24530    
24531                            for (Object value : values) {
24532                                    qPos.add(value);
24533                            }
24534                    }
24535    
24536                    List<JournalArticle> list = q.list();
24537    
24538                    if (list.size() == 2) {
24539                            return list.get(1);
24540                    }
24541                    else {
24542                            return null;
24543                    }
24544            }
24545    
24546            /**
24547             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63; from the database.
24548             *
24549             * @param groupId the group ID
24550             * @param urlTitle the url title
24551             * @param status the status
24552             * @throws SystemException if a system exception occurred
24553             */
24554            public void removeByG_UT_ST(long groupId, String urlTitle, int status)
24555                    throws SystemException {
24556                    for (JournalArticle journalArticle : findByG_UT_ST(groupId, urlTitle,
24557                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
24558                            remove(journalArticle);
24559                    }
24560            }
24561    
24562            /**
24563             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
24564             *
24565             * @param groupId the group ID
24566             * @param urlTitle the url title
24567             * @param status the status
24568             * @return the number of matching journal articles
24569             * @throws SystemException if a system exception occurred
24570             */
24571            public int countByG_UT_ST(long groupId, String urlTitle, int status)
24572                    throws SystemException {
24573                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_UT_ST;
24574    
24575                    Object[] finderArgs = new Object[] { groupId, urlTitle, status };
24576    
24577                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
24578                                    this);
24579    
24580                    if (count == null) {
24581                            StringBundler query = new StringBundler(4);
24582    
24583                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
24584    
24585                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
24586    
24587                            boolean bindUrlTitle = false;
24588    
24589                            if (urlTitle == null) {
24590                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
24591                            }
24592                            else if (urlTitle.equals(StringPool.BLANK)) {
24593                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
24594                            }
24595                            else {
24596                                    bindUrlTitle = true;
24597    
24598                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
24599                            }
24600    
24601                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
24602    
24603                            String sql = query.toString();
24604    
24605                            Session session = null;
24606    
24607                            try {
24608                                    session = openSession();
24609    
24610                                    Query q = session.createQuery(sql);
24611    
24612                                    QueryPos qPos = QueryPos.getInstance(q);
24613    
24614                                    qPos.add(groupId);
24615    
24616                                    if (bindUrlTitle) {
24617                                            qPos.add(urlTitle);
24618                                    }
24619    
24620                                    qPos.add(status);
24621    
24622                                    count = (Long)q.uniqueResult();
24623    
24624                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
24625                            }
24626                            catch (Exception e) {
24627                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
24628    
24629                                    throw processException(e);
24630                            }
24631                            finally {
24632                                    closeSession(session);
24633                            }
24634                    }
24635    
24636                    return count.intValue();
24637            }
24638    
24639            /**
24640             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
24641             *
24642             * @param groupId the group ID
24643             * @param urlTitle the url title
24644             * @param status the status
24645             * @return the number of matching journal articles that the user has permission to view
24646             * @throws SystemException if a system exception occurred
24647             */
24648            public int filterCountByG_UT_ST(long groupId, String urlTitle, int status)
24649                    throws SystemException {
24650                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
24651                            return countByG_UT_ST(groupId, urlTitle, status);
24652                    }
24653    
24654                    StringBundler query = new StringBundler(4);
24655    
24656                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
24657    
24658                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
24659    
24660                    boolean bindUrlTitle = false;
24661    
24662                    if (urlTitle == null) {
24663                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
24664                    }
24665                    else if (urlTitle.equals(StringPool.BLANK)) {
24666                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
24667                    }
24668                    else {
24669                            bindUrlTitle = true;
24670    
24671                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
24672                    }
24673    
24674                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
24675    
24676                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
24677                                    JournalArticle.class.getName(),
24678                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
24679    
24680                    Session session = null;
24681    
24682                    try {
24683                            session = openSession();
24684    
24685                            SQLQuery q = session.createSQLQuery(sql);
24686    
24687                            q.addScalar(COUNT_COLUMN_NAME,
24688                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
24689    
24690                            QueryPos qPos = QueryPos.getInstance(q);
24691    
24692                            qPos.add(groupId);
24693    
24694                            if (bindUrlTitle) {
24695                                    qPos.add(urlTitle);
24696                            }
24697    
24698                            qPos.add(status);
24699    
24700                            Long count = (Long)q.uniqueResult();
24701    
24702                            return count.intValue();
24703                    }
24704                    catch (Exception e) {
24705                            throw processException(e);
24706                    }
24707                    finally {
24708                            closeSession(session);
24709                    }
24710            }
24711    
24712            private static final String _FINDER_COLUMN_G_UT_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
24713            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_1 = "journalArticle.urlTitle IS NULL AND ";
24714            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_2 = "journalArticle.urlTitle = ? AND ";
24715            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = '') AND ";
24716            private static final String _FINDER_COLUMN_G_UT_ST_STATUS_2 = "journalArticle.status = ?";
24717            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24718                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
24719                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
24720                            "findByC_V_ST",
24721                            new String[] {
24722                                    Long.class.getName(), Double.class.getName(),
24723                                    Integer.class.getName(),
24724                                    
24725                            Integer.class.getName(), Integer.class.getName(),
24726                                    OrderByComparator.class.getName()
24727                            });
24728            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST =
24729                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24730                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
24731                            JournalArticleImpl.class,
24732                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_V_ST",
24733                            new String[] {
24734                                    Long.class.getName(), Double.class.getName(),
24735                                    Integer.class.getName()
24736                            },
24737                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
24738                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK |
24739                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
24740                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK);
24741            public static final FinderPath FINDER_PATH_COUNT_BY_C_V_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24742                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
24743                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_V_ST",
24744                            new String[] {
24745                                    Long.class.getName(), Double.class.getName(),
24746                                    Integer.class.getName()
24747                            });
24748    
24749            /**
24750             * Returns all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
24751             *
24752             * @param companyId the company ID
24753             * @param version the version
24754             * @param status the status
24755             * @return the matching journal articles
24756             * @throws SystemException if a system exception occurred
24757             */
24758            public List<JournalArticle> findByC_V_ST(long companyId, double version,
24759                    int status) throws SystemException {
24760                    return findByC_V_ST(companyId, version, status, QueryUtil.ALL_POS,
24761                            QueryUtil.ALL_POS, null);
24762            }
24763    
24764            /**
24765             * Returns a range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
24766             *
24767             * <p>
24768             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
24769             * </p>
24770             *
24771             * @param companyId the company ID
24772             * @param version the version
24773             * @param status the status
24774             * @param start the lower bound of the range of journal articles
24775             * @param end the upper bound of the range of journal articles (not inclusive)
24776             * @return the range of matching journal articles
24777             * @throws SystemException if a system exception occurred
24778             */
24779            public List<JournalArticle> findByC_V_ST(long companyId, double version,
24780                    int status, int start, int end) throws SystemException {
24781                    return findByC_V_ST(companyId, version, status, start, end, null);
24782            }
24783    
24784            /**
24785             * Returns an ordered range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
24786             *
24787             * <p>
24788             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
24789             * </p>
24790             *
24791             * @param companyId the company ID
24792             * @param version the version
24793             * @param status the status
24794             * @param start the lower bound of the range of journal articles
24795             * @param end the upper bound of the range of journal articles (not inclusive)
24796             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
24797             * @return the ordered range of matching journal articles
24798             * @throws SystemException if a system exception occurred
24799             */
24800            public List<JournalArticle> findByC_V_ST(long companyId, double version,
24801                    int status, int start, int end, OrderByComparator orderByComparator)
24802                    throws SystemException {
24803                    boolean pagination = true;
24804                    FinderPath finderPath = null;
24805                    Object[] finderArgs = null;
24806    
24807                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
24808                                    (orderByComparator == null)) {
24809                            pagination = false;
24810                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST;
24811                            finderArgs = new Object[] { companyId, version, status };
24812                    }
24813                    else {
24814                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V_ST;
24815                            finderArgs = new Object[] {
24816                                            companyId, version, status,
24817                                            
24818                                            start, end, orderByComparator
24819                                    };
24820                    }
24821    
24822                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
24823                                    finderArgs, this);
24824    
24825                    if ((list != null) && !list.isEmpty()) {
24826                            for (JournalArticle journalArticle : list) {
24827                                    if ((companyId != journalArticle.getCompanyId()) ||
24828                                                    (version != journalArticle.getVersion()) ||
24829                                                    (status != journalArticle.getStatus())) {
24830                                            list = null;
24831    
24832                                            break;
24833                                    }
24834                            }
24835                    }
24836    
24837                    if (list == null) {
24838                            StringBundler query = null;
24839    
24840                            if (orderByComparator != null) {
24841                                    query = new StringBundler(5 +
24842                                                    (orderByComparator.getOrderByFields().length * 3));
24843                            }
24844                            else {
24845                                    query = new StringBundler(5);
24846                            }
24847    
24848                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
24849    
24850                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
24851    
24852                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
24853    
24854                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
24855    
24856                            if (orderByComparator != null) {
24857                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
24858                                            orderByComparator);
24859                            }
24860                            else
24861                             if (pagination) {
24862                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
24863                            }
24864    
24865                            String sql = query.toString();
24866    
24867                            Session session = null;
24868    
24869                            try {
24870                                    session = openSession();
24871    
24872                                    Query q = session.createQuery(sql);
24873    
24874                                    QueryPos qPos = QueryPos.getInstance(q);
24875    
24876                                    qPos.add(companyId);
24877    
24878                                    qPos.add(version);
24879    
24880                                    qPos.add(status);
24881    
24882                                    if (!pagination) {
24883                                            list = (List<JournalArticle>)QueryUtil.list(q,
24884                                                            getDialect(), start, end, false);
24885    
24886                                            Collections.sort(list);
24887    
24888                                            list = new UnmodifiableList<JournalArticle>(list);
24889                                    }
24890                                    else {
24891                                            list = (List<JournalArticle>)QueryUtil.list(q,
24892                                                            getDialect(), start, end);
24893                                    }
24894    
24895                                    cacheResult(list);
24896    
24897                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
24898                            }
24899                            catch (Exception e) {
24900                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
24901    
24902                                    throw processException(e);
24903                            }
24904                            finally {
24905                                    closeSession(session);
24906                            }
24907                    }
24908    
24909                    return list;
24910            }
24911    
24912            /**
24913             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
24914             *
24915             * @param companyId the company ID
24916             * @param version the version
24917             * @param status the status
24918             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24919             * @return the first matching journal article
24920             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
24921             * @throws SystemException if a system exception occurred
24922             */
24923            public JournalArticle findByC_V_ST_First(long companyId, double version,
24924                    int status, OrderByComparator orderByComparator)
24925                    throws NoSuchArticleException, SystemException {
24926                    JournalArticle journalArticle = fetchByC_V_ST_First(companyId, version,
24927                                    status, orderByComparator);
24928    
24929                    if (journalArticle != null) {
24930                            return journalArticle;
24931                    }
24932    
24933                    StringBundler msg = new StringBundler(8);
24934    
24935                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
24936    
24937                    msg.append("companyId=");
24938                    msg.append(companyId);
24939    
24940                    msg.append(", version=");
24941                    msg.append(version);
24942    
24943                    msg.append(", status=");
24944                    msg.append(status);
24945    
24946                    msg.append(StringPool.CLOSE_CURLY_BRACE);
24947    
24948                    throw new NoSuchArticleException(msg.toString());
24949            }
24950    
24951            /**
24952             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
24953             *
24954             * @param companyId the company ID
24955             * @param version the version
24956             * @param status the status
24957             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24958             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
24959             * @throws SystemException if a system exception occurred
24960             */
24961            public JournalArticle fetchByC_V_ST_First(long companyId, double version,
24962                    int status, OrderByComparator orderByComparator)
24963                    throws SystemException {
24964                    List<JournalArticle> list = findByC_V_ST(companyId, version, status, 0,
24965                                    1, orderByComparator);
24966    
24967                    if (!list.isEmpty()) {
24968                            return list.get(0);
24969                    }
24970    
24971                    return null;
24972            }
24973    
24974            /**
24975             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
24976             *
24977             * @param companyId the company ID
24978             * @param version the version
24979             * @param status the status
24980             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24981             * @return the last matching journal article
24982             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
24983             * @throws SystemException if a system exception occurred
24984             */
24985            public JournalArticle findByC_V_ST_Last(long companyId, double version,
24986                    int status, OrderByComparator orderByComparator)
24987                    throws NoSuchArticleException, SystemException {
24988                    JournalArticle journalArticle = fetchByC_V_ST_Last(companyId, version,
24989                                    status, orderByComparator);
24990    
24991                    if (journalArticle != null) {
24992                            return journalArticle;
24993                    }
24994    
24995                    StringBundler msg = new StringBundler(8);
24996    
24997                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
24998    
24999                    msg.append("companyId=");
25000                    msg.append(companyId);
25001    
25002                    msg.append(", version=");
25003                    msg.append(version);
25004    
25005                    msg.append(", status=");
25006                    msg.append(status);
25007    
25008                    msg.append(StringPool.CLOSE_CURLY_BRACE);
25009    
25010                    throw new NoSuchArticleException(msg.toString());
25011            }
25012    
25013            /**
25014             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
25015             *
25016             * @param companyId the company ID
25017             * @param version the version
25018             * @param status the status
25019             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25020             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
25021             * @throws SystemException if a system exception occurred
25022             */
25023            public JournalArticle fetchByC_V_ST_Last(long companyId, double version,
25024                    int status, OrderByComparator orderByComparator)
25025                    throws SystemException {
25026                    int count = countByC_V_ST(companyId, version, status);
25027    
25028                    List<JournalArticle> list = findByC_V_ST(companyId, version, status,
25029                                    count - 1, count, orderByComparator);
25030    
25031                    if (!list.isEmpty()) {
25032                            return list.get(0);
25033                    }
25034    
25035                    return null;
25036            }
25037    
25038            /**
25039             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
25040             *
25041             * @param id the primary key of the current journal article
25042             * @param companyId the company ID
25043             * @param version the version
25044             * @param status the status
25045             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25046             * @return the previous, current, and next journal article
25047             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
25048             * @throws SystemException if a system exception occurred
25049             */
25050            public JournalArticle[] findByC_V_ST_PrevAndNext(long id, long companyId,
25051                    double version, int status, OrderByComparator orderByComparator)
25052                    throws NoSuchArticleException, SystemException {
25053                    JournalArticle journalArticle = findByPrimaryKey(id);
25054    
25055                    Session session = null;
25056    
25057                    try {
25058                            session = openSession();
25059    
25060                            JournalArticle[] array = new JournalArticleImpl[3];
25061    
25062                            array[0] = getByC_V_ST_PrevAndNext(session, journalArticle,
25063                                            companyId, version, status, orderByComparator, true);
25064    
25065                            array[1] = journalArticle;
25066    
25067                            array[2] = getByC_V_ST_PrevAndNext(session, journalArticle,
25068                                            companyId, version, status, orderByComparator, false);
25069    
25070                            return array;
25071                    }
25072                    catch (Exception e) {
25073                            throw processException(e);
25074                    }
25075                    finally {
25076                            closeSession(session);
25077                    }
25078            }
25079    
25080            protected JournalArticle getByC_V_ST_PrevAndNext(Session session,
25081                    JournalArticle journalArticle, long companyId, double version,
25082                    int status, OrderByComparator orderByComparator, boolean previous) {
25083                    StringBundler query = null;
25084    
25085                    if (orderByComparator != null) {
25086                            query = new StringBundler(6 +
25087                                            (orderByComparator.getOrderByFields().length * 6));
25088                    }
25089                    else {
25090                            query = new StringBundler(3);
25091                    }
25092    
25093                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
25094    
25095                    query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
25096    
25097                    query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
25098    
25099                    query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
25100    
25101                    if (orderByComparator != null) {
25102                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
25103    
25104                            if (orderByConditionFields.length > 0) {
25105                                    query.append(WHERE_AND);
25106                            }
25107    
25108                            for (int i = 0; i < orderByConditionFields.length; i++) {
25109                                    query.append(_ORDER_BY_ENTITY_ALIAS);
25110                                    query.append(orderByConditionFields[i]);
25111    
25112                                    if ((i + 1) < orderByConditionFields.length) {
25113                                            if (orderByComparator.isAscending() ^ previous) {
25114                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
25115                                            }
25116                                            else {
25117                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
25118                                            }
25119                                    }
25120                                    else {
25121                                            if (orderByComparator.isAscending() ^ previous) {
25122                                                    query.append(WHERE_GREATER_THAN);
25123                                            }
25124                                            else {
25125                                                    query.append(WHERE_LESSER_THAN);
25126                                            }
25127                                    }
25128                            }
25129    
25130                            query.append(ORDER_BY_CLAUSE);
25131    
25132                            String[] orderByFields = orderByComparator.getOrderByFields();
25133    
25134                            for (int i = 0; i < orderByFields.length; i++) {
25135                                    query.append(_ORDER_BY_ENTITY_ALIAS);
25136                                    query.append(orderByFields[i]);
25137    
25138                                    if ((i + 1) < orderByFields.length) {
25139                                            if (orderByComparator.isAscending() ^ previous) {
25140                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
25141                                            }
25142                                            else {
25143                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
25144                                            }
25145                                    }
25146                                    else {
25147                                            if (orderByComparator.isAscending() ^ previous) {
25148                                                    query.append(ORDER_BY_ASC);
25149                                            }
25150                                            else {
25151                                                    query.append(ORDER_BY_DESC);
25152                                            }
25153                                    }
25154                            }
25155                    }
25156                    else {
25157                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
25158                    }
25159    
25160                    String sql = query.toString();
25161    
25162                    Query q = session.createQuery(sql);
25163    
25164                    q.setFirstResult(0);
25165                    q.setMaxResults(2);
25166    
25167                    QueryPos qPos = QueryPos.getInstance(q);
25168    
25169                    qPos.add(companyId);
25170    
25171                    qPos.add(version);
25172    
25173                    qPos.add(status);
25174    
25175                    if (orderByComparator != null) {
25176                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
25177    
25178                            for (Object value : values) {
25179                                    qPos.add(value);
25180                            }
25181                    }
25182    
25183                    List<JournalArticle> list = q.list();
25184    
25185                    if (list.size() == 2) {
25186                            return list.get(1);
25187                    }
25188                    else {
25189                            return null;
25190                    }
25191            }
25192    
25193            /**
25194             * Removes all the journal articles where companyId = &#63; and version = &#63; and status = &#63; from the database.
25195             *
25196             * @param companyId the company ID
25197             * @param version the version
25198             * @param status the status
25199             * @throws SystemException if a system exception occurred
25200             */
25201            public void removeByC_V_ST(long companyId, double version, int status)
25202                    throws SystemException {
25203                    for (JournalArticle journalArticle : findByC_V_ST(companyId, version,
25204                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
25205                            remove(journalArticle);
25206                    }
25207            }
25208    
25209            /**
25210             * Returns the number of journal articles where companyId = &#63; and version = &#63; and status = &#63;.
25211             *
25212             * @param companyId the company ID
25213             * @param version the version
25214             * @param status the status
25215             * @return the number of matching journal articles
25216             * @throws SystemException if a system exception occurred
25217             */
25218            public int countByC_V_ST(long companyId, double version, int status)
25219                    throws SystemException {
25220                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_V_ST;
25221    
25222                    Object[] finderArgs = new Object[] { companyId, version, status };
25223    
25224                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
25225                                    this);
25226    
25227                    if (count == null) {
25228                            StringBundler query = new StringBundler(4);
25229    
25230                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
25231    
25232                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
25233    
25234                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
25235    
25236                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
25237    
25238                            String sql = query.toString();
25239    
25240                            Session session = null;
25241    
25242                            try {
25243                                    session = openSession();
25244    
25245                                    Query q = session.createQuery(sql);
25246    
25247                                    QueryPos qPos = QueryPos.getInstance(q);
25248    
25249                                    qPos.add(companyId);
25250    
25251                                    qPos.add(version);
25252    
25253                                    qPos.add(status);
25254    
25255                                    count = (Long)q.uniqueResult();
25256    
25257                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
25258                            }
25259                            catch (Exception e) {
25260                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
25261    
25262                                    throw processException(e);
25263                            }
25264                            finally {
25265                                    closeSession(session);
25266                            }
25267                    }
25268    
25269                    return count.intValue();
25270            }
25271    
25272            private static final String _FINDER_COLUMN_C_V_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
25273            private static final String _FINDER_COLUMN_C_V_ST_VERSION_2 = "journalArticle.version = ? AND ";
25274            private static final String _FINDER_COLUMN_C_V_ST_STATUS_2 = "journalArticle.status = ?";
25275    
25276            /**
25277             * Caches the journal article in the entity cache if it is enabled.
25278             *
25279             * @param journalArticle the journal article
25280             */
25281            public void cacheResult(JournalArticle journalArticle) {
25282                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
25283                            JournalArticleImpl.class, journalArticle.getPrimaryKey(),
25284                            journalArticle);
25285    
25286                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
25287                            new Object[] { journalArticle.getUuid(), journalArticle.getGroupId() },
25288                            journalArticle);
25289    
25290                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
25291                            new Object[] {
25292                                    journalArticle.getGroupId(), journalArticle.getClassNameId(),
25293                                    journalArticle.getStructureId()
25294                            }, journalArticle);
25295    
25296                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
25297                            new Object[] {
25298                                    journalArticle.getGroupId(), journalArticle.getArticleId(),
25299                                    journalArticle.getVersion()
25300                            }, journalArticle);
25301    
25302                    journalArticle.resetOriginalValues();
25303            }
25304    
25305            /**
25306             * Caches the journal articles in the entity cache if it is enabled.
25307             *
25308             * @param journalArticles the journal articles
25309             */
25310            public void cacheResult(List<JournalArticle> journalArticles) {
25311                    for (JournalArticle journalArticle : journalArticles) {
25312                            if (EntityCacheUtil.getResult(
25313                                                    JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
25314                                                    JournalArticleImpl.class, journalArticle.getPrimaryKey()) == null) {
25315                                    cacheResult(journalArticle);
25316                            }
25317                            else {
25318                                    journalArticle.resetOriginalValues();
25319                            }
25320                    }
25321            }
25322    
25323            /**
25324             * Clears the cache for all journal articles.
25325             *
25326             * <p>
25327             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
25328             * </p>
25329             */
25330            @Override
25331            public void clearCache() {
25332                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
25333                            CacheRegistryUtil.clear(JournalArticleImpl.class.getName());
25334                    }
25335    
25336                    EntityCacheUtil.clearCache(JournalArticleImpl.class.getName());
25337    
25338                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
25339                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
25340                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
25341            }
25342    
25343            /**
25344             * Clears the cache for the journal article.
25345             *
25346             * <p>
25347             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
25348             * </p>
25349             */
25350            @Override
25351            public void clearCache(JournalArticle journalArticle) {
25352                    EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
25353                            JournalArticleImpl.class, journalArticle.getPrimaryKey());
25354    
25355                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
25356                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
25357    
25358                    clearUniqueFindersCache(journalArticle);
25359            }
25360    
25361            @Override
25362            public void clearCache(List<JournalArticle> journalArticles) {
25363                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
25364                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
25365    
25366                    for (JournalArticle journalArticle : journalArticles) {
25367                            EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
25368                                    JournalArticleImpl.class, journalArticle.getPrimaryKey());
25369    
25370                            clearUniqueFindersCache(journalArticle);
25371                    }
25372            }
25373    
25374            protected void cacheUniqueFindersCache(JournalArticle journalArticle) {
25375                    if (journalArticle.isNew()) {
25376                            Object[] args = new Object[] {
25377                                            journalArticle.getUuid(), journalArticle.getGroupId()
25378                                    };
25379    
25380                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
25381                                    Long.valueOf(1));
25382                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
25383                                    journalArticle);
25384    
25385                            args = new Object[] {
25386                                            journalArticle.getGroupId(), journalArticle.getClassNameId(),
25387                                            journalArticle.getStructureId()
25388                                    };
25389    
25390                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S, args,
25391                                    Long.valueOf(1));
25392                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S, args,
25393                                    journalArticle);
25394    
25395                            args = new Object[] {
25396                                            journalArticle.getGroupId(), journalArticle.getArticleId(),
25397                                            journalArticle.getVersion()
25398                                    };
25399    
25400                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V, args,
25401                                    Long.valueOf(1));
25402                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V, args,
25403                                    journalArticle);
25404                    }
25405                    else {
25406                            JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
25407    
25408                            if ((journalArticleModelImpl.getColumnBitmask() &
25409                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
25410                                    Object[] args = new Object[] {
25411                                                    journalArticle.getUuid(), journalArticle.getGroupId()
25412                                            };
25413    
25414                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
25415                                            Long.valueOf(1));
25416                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
25417                                            journalArticle);
25418                            }
25419    
25420                            if ((journalArticleModelImpl.getColumnBitmask() &
25421                                            FINDER_PATH_FETCH_BY_G_C_S.getColumnBitmask()) != 0) {
25422                                    Object[] args = new Object[] {
25423                                                    journalArticle.getGroupId(),
25424                                                    journalArticle.getClassNameId(),
25425                                                    journalArticle.getStructureId()
25426                                            };
25427    
25428                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S, args,
25429                                            Long.valueOf(1));
25430                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S, args,
25431                                            journalArticle);
25432                            }
25433    
25434                            if ((journalArticleModelImpl.getColumnBitmask() &
25435                                            FINDER_PATH_FETCH_BY_G_A_V.getColumnBitmask()) != 0) {
25436                                    Object[] args = new Object[] {
25437                                                    journalArticle.getGroupId(),
25438                                                    journalArticle.getArticleId(),
25439                                                    journalArticle.getVersion()
25440                                            };
25441    
25442                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V, args,
25443                                            Long.valueOf(1));
25444                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V, args,
25445                                            journalArticle);
25446                            }
25447                    }
25448            }
25449    
25450            protected void clearUniqueFindersCache(JournalArticle journalArticle) {
25451                    JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
25452    
25453                    Object[] args = new Object[] {
25454                                    journalArticle.getUuid(), journalArticle.getGroupId()
25455                            };
25456    
25457                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
25458                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
25459    
25460                    if ((journalArticleModelImpl.getColumnBitmask() &
25461                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
25462                            args = new Object[] {
25463                                            journalArticleModelImpl.getOriginalUuid(),
25464                                            journalArticleModelImpl.getOriginalGroupId()
25465                                    };
25466    
25467                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
25468                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
25469                    }
25470    
25471                    args = new Object[] {
25472                                    journalArticle.getGroupId(), journalArticle.getClassNameId(),
25473                                    journalArticle.getStructureId()
25474                            };
25475    
25476                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
25477                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S, args);
25478    
25479                    if ((journalArticleModelImpl.getColumnBitmask() &
25480                                    FINDER_PATH_FETCH_BY_G_C_S.getColumnBitmask()) != 0) {
25481                            args = new Object[] {
25482                                            journalArticleModelImpl.getOriginalGroupId(),
25483                                            journalArticleModelImpl.getOriginalClassNameId(),
25484                                            journalArticleModelImpl.getOriginalStructureId()
25485                                    };
25486    
25487                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
25488                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S, args);
25489                    }
25490    
25491                    args = new Object[] {
25492                                    journalArticle.getGroupId(), journalArticle.getArticleId(),
25493                                    journalArticle.getVersion()
25494                            };
25495    
25496                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_V, args);
25497                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V, args);
25498    
25499                    if ((journalArticleModelImpl.getColumnBitmask() &
25500                                    FINDER_PATH_FETCH_BY_G_A_V.getColumnBitmask()) != 0) {
25501                            args = new Object[] {
25502                                            journalArticleModelImpl.getOriginalGroupId(),
25503                                            journalArticleModelImpl.getOriginalArticleId(),
25504                                            journalArticleModelImpl.getOriginalVersion()
25505                                    };
25506    
25507                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_V, args);
25508                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V, args);
25509                    }
25510            }
25511    
25512            /**
25513             * Creates a new journal article with the primary key. Does not add the journal article to the database.
25514             *
25515             * @param id the primary key for the new journal article
25516             * @return the new journal article
25517             */
25518            public JournalArticle create(long id) {
25519                    JournalArticle journalArticle = new JournalArticleImpl();
25520    
25521                    journalArticle.setNew(true);
25522                    journalArticle.setPrimaryKey(id);
25523    
25524                    String uuid = PortalUUIDUtil.generate();
25525    
25526                    journalArticle.setUuid(uuid);
25527    
25528                    return journalArticle;
25529            }
25530    
25531            /**
25532             * Removes the journal article with the primary key from the database. Also notifies the appropriate model listeners.
25533             *
25534             * @param id the primary key of the journal article
25535             * @return the journal article that was removed
25536             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
25537             * @throws SystemException if a system exception occurred
25538             */
25539            public JournalArticle remove(long id)
25540                    throws NoSuchArticleException, SystemException {
25541                    return remove((Serializable)id);
25542            }
25543    
25544            /**
25545             * Removes the journal article with the primary key from the database. Also notifies the appropriate model listeners.
25546             *
25547             * @param primaryKey the primary key of the journal article
25548             * @return the journal article that was removed
25549             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
25550             * @throws SystemException if a system exception occurred
25551             */
25552            @Override
25553            public JournalArticle remove(Serializable primaryKey)
25554                    throws NoSuchArticleException, SystemException {
25555                    Session session = null;
25556    
25557                    try {
25558                            session = openSession();
25559    
25560                            JournalArticle journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
25561                                            primaryKey);
25562    
25563                            if (journalArticle == null) {
25564                                    if (_log.isWarnEnabled()) {
25565                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
25566                                    }
25567    
25568                                    throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
25569                                            primaryKey);
25570                            }
25571    
25572                            return remove(journalArticle);
25573                    }
25574                    catch (NoSuchArticleException nsee) {
25575                            throw nsee;
25576                    }
25577                    catch (Exception e) {
25578                            throw processException(e);
25579                    }
25580                    finally {
25581                            closeSession(session);
25582                    }
25583            }
25584    
25585            @Override
25586            protected JournalArticle removeImpl(JournalArticle journalArticle)
25587                    throws SystemException {
25588                    journalArticle = toUnwrappedModel(journalArticle);
25589    
25590                    Session session = null;
25591    
25592                    try {
25593                            session = openSession();
25594    
25595                            if (!session.contains(journalArticle)) {
25596                                    journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
25597                                                    journalArticle.getPrimaryKeyObj());
25598                            }
25599    
25600                            if (journalArticle != null) {
25601                                    session.delete(journalArticle);
25602                            }
25603                    }
25604                    catch (Exception e) {
25605                            throw processException(e);
25606                    }
25607                    finally {
25608                            closeSession(session);
25609                    }
25610    
25611                    if (journalArticle != null) {
25612                            clearCache(journalArticle);
25613                    }
25614    
25615                    return journalArticle;
25616            }
25617    
25618            @Override
25619            public JournalArticle updateImpl(
25620                    com.liferay.portlet.journal.model.JournalArticle journalArticle)
25621                    throws SystemException {
25622                    journalArticle = toUnwrappedModel(journalArticle);
25623    
25624                    boolean isNew = journalArticle.isNew();
25625    
25626                    JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
25627    
25628                    if (Validator.isNull(journalArticle.getUuid())) {
25629                            String uuid = PortalUUIDUtil.generate();
25630    
25631                            journalArticle.setUuid(uuid);
25632                    }
25633    
25634                    Session session = null;
25635    
25636                    try {
25637                            session = openSession();
25638    
25639                            if (journalArticle.isNew()) {
25640                                    session.save(journalArticle);
25641    
25642                                    journalArticle.setNew(false);
25643                            }
25644                            else {
25645                                    session.merge(journalArticle);
25646                            }
25647                    }
25648                    catch (Exception e) {
25649                            throw processException(e);
25650                    }
25651                    finally {
25652                            closeSession(session);
25653                    }
25654    
25655                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
25656    
25657                    if (isNew || !JournalArticleModelImpl.COLUMN_BITMASK_ENABLED) {
25658                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
25659                    }
25660    
25661                    else {
25662                            if ((journalArticleModelImpl.getColumnBitmask() &
25663                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
25664                                    Object[] args = new Object[] {
25665                                                    journalArticleModelImpl.getOriginalUuid()
25666                                            };
25667    
25668                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
25669                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
25670                                            args);
25671    
25672                                    args = new Object[] { journalArticleModelImpl.getUuid() };
25673    
25674                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
25675                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
25676                                            args);
25677                            }
25678    
25679                            if ((journalArticleModelImpl.getColumnBitmask() &
25680                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
25681                                    Object[] args = new Object[] {
25682                                                    journalArticleModelImpl.getOriginalUuid(),
25683                                                    journalArticleModelImpl.getOriginalCompanyId()
25684                                            };
25685    
25686                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
25687                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
25688                                            args);
25689    
25690                                    args = new Object[] {
25691                                                    journalArticleModelImpl.getUuid(),
25692                                                    journalArticleModelImpl.getCompanyId()
25693                                            };
25694    
25695                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
25696                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
25697                                            args);
25698                            }
25699    
25700                            if ((journalArticleModelImpl.getColumnBitmask() &
25701                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY.getColumnBitmask()) != 0) {
25702                                    Object[] args = new Object[] {
25703                                                    journalArticleModelImpl.getOriginalResourcePrimKey()
25704                                            };
25705    
25706                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
25707                                            args);
25708                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
25709                                            args);
25710    
25711                                    args = new Object[] { journalArticleModelImpl.getResourcePrimKey() };
25712    
25713                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
25714                                            args);
25715                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
25716                                            args);
25717                            }
25718    
25719                            if ((journalArticleModelImpl.getColumnBitmask() &
25720                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
25721                                    Object[] args = new Object[] {
25722                                                    journalArticleModelImpl.getOriginalGroupId()
25723                                            };
25724    
25725                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
25726                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
25727                                            args);
25728    
25729                                    args = new Object[] { journalArticleModelImpl.getGroupId() };
25730    
25731                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
25732                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
25733                                            args);
25734                            }
25735    
25736                            if ((journalArticleModelImpl.getColumnBitmask() &
25737                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
25738                                    Object[] args = new Object[] {
25739                                                    journalArticleModelImpl.getOriginalCompanyId()
25740                                            };
25741    
25742                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
25743                                            args);
25744                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
25745                                            args);
25746    
25747                                    args = new Object[] { journalArticleModelImpl.getCompanyId() };
25748    
25749                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
25750                                            args);
25751                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
25752                                            args);
25753                            }
25754    
25755                            if ((journalArticleModelImpl.getColumnBitmask() &
25756                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID.getColumnBitmask()) != 0) {
25757                                    Object[] args = new Object[] {
25758                                                    journalArticleModelImpl.getOriginalStructureId()
25759                                            };
25760    
25761                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
25762                                            args);
25763                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
25764                                            args);
25765    
25766                                    args = new Object[] { journalArticleModelImpl.getStructureId() };
25767    
25768                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
25769                                            args);
25770                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
25771                                            args);
25772                            }
25773    
25774                            if ((journalArticleModelImpl.getColumnBitmask() &
25775                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID.getColumnBitmask()) != 0) {
25776                                    Object[] args = new Object[] {
25777                                                    journalArticleModelImpl.getOriginalTemplateId()
25778                                            };
25779    
25780                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
25781                                            args);
25782                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID,
25783                                            args);
25784    
25785                                    args = new Object[] { journalArticleModelImpl.getTemplateId() };
25786    
25787                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
25788                                            args);
25789                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID,
25790                                            args);
25791                            }
25792    
25793                            if ((journalArticleModelImpl.getColumnBitmask() &
25794                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID.getColumnBitmask()) != 0) {
25795                                    Object[] args = new Object[] {
25796                                                    journalArticleModelImpl.getOriginalLayoutUuid()
25797                                            };
25798    
25799                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTUUID,
25800                                            args);
25801                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID,
25802                                            args);
25803    
25804                                    args = new Object[] { journalArticleModelImpl.getLayoutUuid() };
25805    
25806                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTUUID,
25807                                            args);
25808                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID,
25809                                            args);
25810                            }
25811    
25812                            if ((journalArticleModelImpl.getColumnBitmask() &
25813                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID.getColumnBitmask()) != 0) {
25814                                    Object[] args = new Object[] {
25815                                                    journalArticleModelImpl.getOriginalSmallImageId()
25816                                            };
25817    
25818                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
25819                                            args);
25820                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID,
25821                                            args);
25822    
25823                                    args = new Object[] { journalArticleModelImpl.getSmallImageId() };
25824    
25825                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
25826                                            args);
25827                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID,
25828                                            args);
25829                            }
25830    
25831                            if ((journalArticleModelImpl.getColumnBitmask() &
25832                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST.getColumnBitmask()) != 0) {
25833                                    Object[] args = new Object[] {
25834                                                    journalArticleModelImpl.getOriginalResourcePrimKey(),
25835                                                    journalArticleModelImpl.getOriginalStatus()
25836                                            };
25837    
25838                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_ST, args);
25839                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST,
25840                                            args);
25841    
25842                                    args = new Object[] {
25843                                                    journalArticleModelImpl.getResourcePrimKey(),
25844                                                    journalArticleModelImpl.getStatus()
25845                                            };
25846    
25847                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_ST, args);
25848                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST,
25849                                            args);
25850                            }
25851    
25852                            if ((journalArticleModelImpl.getColumnBitmask() &
25853                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U.getColumnBitmask()) != 0) {
25854                                    Object[] args = new Object[] {
25855                                                    journalArticleModelImpl.getOriginalGroupId(),
25856                                                    journalArticleModelImpl.getOriginalUserId()
25857                                            };
25858    
25859                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
25860                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
25861                                            args);
25862    
25863                                    args = new Object[] {
25864                                                    journalArticleModelImpl.getGroupId(),
25865                                                    journalArticleModelImpl.getUserId()
25866                                            };
25867    
25868                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
25869                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
25870                                            args);
25871                            }
25872    
25873                            if ((journalArticleModelImpl.getColumnBitmask() &
25874                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F.getColumnBitmask()) != 0) {
25875                                    Object[] args = new Object[] {
25876                                                    journalArticleModelImpl.getOriginalGroupId(),
25877                                                    journalArticleModelImpl.getOriginalFolderId()
25878                                            };
25879    
25880                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
25881                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
25882                                            args);
25883    
25884                                    args = new Object[] {
25885                                                    journalArticleModelImpl.getGroupId(),
25886                                                    journalArticleModelImpl.getFolderId()
25887                                            };
25888    
25889                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
25890                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
25891                                            args);
25892                            }
25893    
25894                            if ((journalArticleModelImpl.getColumnBitmask() &
25895                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A.getColumnBitmask()) != 0) {
25896                                    Object[] args = new Object[] {
25897                                                    journalArticleModelImpl.getOriginalGroupId(),
25898                                                    journalArticleModelImpl.getOriginalArticleId()
25899                                            };
25900    
25901                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
25902                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
25903                                            args);
25904    
25905                                    args = new Object[] {
25906                                                    journalArticleModelImpl.getGroupId(),
25907                                                    journalArticleModelImpl.getArticleId()
25908                                            };
25909    
25910                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
25911                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
25912                                            args);
25913                            }
25914    
25915                            if ((journalArticleModelImpl.getColumnBitmask() &
25916                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT.getColumnBitmask()) != 0) {
25917                                    Object[] args = new Object[] {
25918                                                    journalArticleModelImpl.getOriginalGroupId(),
25919                                                    journalArticleModelImpl.getOriginalUrlTitle()
25920                                            };
25921    
25922                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
25923                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT,
25924                                            args);
25925    
25926                                    args = new Object[] {
25927                                                    journalArticleModelImpl.getGroupId(),
25928                                                    journalArticleModelImpl.getUrlTitle()
25929                                            };
25930    
25931                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
25932                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT,
25933                                            args);
25934                            }
25935    
25936                            if ((journalArticleModelImpl.getColumnBitmask() &
25937                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
25938                                    Object[] args = new Object[] {
25939                                                    journalArticleModelImpl.getOriginalGroupId(),
25940                                                    journalArticleModelImpl.getOriginalStructureId()
25941                                            };
25942    
25943                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
25944                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
25945                                            args);
25946    
25947                                    args = new Object[] {
25948                                                    journalArticleModelImpl.getGroupId(),
25949                                                    journalArticleModelImpl.getStructureId()
25950                                            };
25951    
25952                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
25953                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
25954                                            args);
25955                            }
25956    
25957                            if ((journalArticleModelImpl.getColumnBitmask() &
25958                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T.getColumnBitmask()) != 0) {
25959                                    Object[] args = new Object[] {
25960                                                    journalArticleModelImpl.getOriginalGroupId(),
25961                                                    journalArticleModelImpl.getOriginalTemplateId()
25962                                            };
25963    
25964                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_T, args);
25965                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T,
25966                                            args);
25967    
25968                                    args = new Object[] {
25969                                                    journalArticleModelImpl.getGroupId(),
25970                                                    journalArticleModelImpl.getTemplateId()
25971                                            };
25972    
25973                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_T, args);
25974                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T,
25975                                            args);
25976                            }
25977    
25978                            if ((journalArticleModelImpl.getColumnBitmask() &
25979                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L.getColumnBitmask()) != 0) {
25980                                    Object[] args = new Object[] {
25981                                                    journalArticleModelImpl.getOriginalGroupId(),
25982                                                    journalArticleModelImpl.getOriginalLayoutUuid()
25983                                            };
25984    
25985                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_L, args);
25986                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L,
25987                                            args);
25988    
25989                                    args = new Object[] {
25990                                                    journalArticleModelImpl.getGroupId(),
25991                                                    journalArticleModelImpl.getLayoutUuid()
25992                                            };
25993    
25994                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_L, args);
25995                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L,
25996                                            args);
25997                            }
25998    
25999                            if ((journalArticleModelImpl.getColumnBitmask() &
26000                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST.getColumnBitmask()) != 0) {
26001                                    Object[] args = new Object[] {
26002                                                    journalArticleModelImpl.getOriginalGroupId(),
26003                                                    journalArticleModelImpl.getOriginalStatus()
26004                                            };
26005    
26006                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_ST, args);
26007                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST,
26008                                            args);
26009    
26010                                    args = new Object[] {
26011                                                    journalArticleModelImpl.getGroupId(),
26012                                                    journalArticleModelImpl.getStatus()
26013                                            };
26014    
26015                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_ST, args);
26016                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST,
26017                                            args);
26018                            }
26019    
26020                            if ((journalArticleModelImpl.getColumnBitmask() &
26021                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V.getColumnBitmask()) != 0) {
26022                                    Object[] args = new Object[] {
26023                                                    journalArticleModelImpl.getOriginalCompanyId(),
26024                                                    journalArticleModelImpl.getOriginalVersion()
26025                                            };
26026    
26027                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V, args);
26028                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V,
26029                                            args);
26030    
26031                                    args = new Object[] {
26032                                                    journalArticleModelImpl.getCompanyId(),
26033                                                    journalArticleModelImpl.getVersion()
26034                                            };
26035    
26036                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V, args);
26037                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V,
26038                                            args);
26039                            }
26040    
26041                            if ((journalArticleModelImpl.getColumnBitmask() &
26042                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST.getColumnBitmask()) != 0) {
26043                                    Object[] args = new Object[] {
26044                                                    journalArticleModelImpl.getOriginalCompanyId(),
26045                                                    journalArticleModelImpl.getOriginalStatus()
26046                                            };
26047    
26048                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_ST, args);
26049                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST,
26050                                            args);
26051    
26052                                    args = new Object[] {
26053                                                    journalArticleModelImpl.getCompanyId(),
26054                                                    journalArticleModelImpl.getStatus()
26055                                            };
26056    
26057                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_ST, args);
26058                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST,
26059                                            args);
26060                            }
26061    
26062                            if ((journalArticleModelImpl.getColumnBitmask() &
26063                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST.getColumnBitmask()) != 0) {
26064                                    Object[] args = new Object[] {
26065                                                    journalArticleModelImpl.getOriginalGroupId(),
26066                                                    journalArticleModelImpl.getOriginalFolderId(),
26067                                                    journalArticleModelImpl.getOriginalStatus()
26068                                            };
26069    
26070                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_ST, args);
26071                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST,
26072                                            args);
26073    
26074                                    args = new Object[] {
26075                                                    journalArticleModelImpl.getGroupId(),
26076                                                    journalArticleModelImpl.getFolderId(),
26077                                                    journalArticleModelImpl.getStatus()
26078                                            };
26079    
26080                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_ST, args);
26081                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST,
26082                                            args);
26083                            }
26084    
26085                            if ((journalArticleModelImpl.getColumnBitmask() &
26086                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C.getColumnBitmask()) != 0) {
26087                                    Object[] args = new Object[] {
26088                                                    journalArticleModelImpl.getOriginalGroupId(),
26089                                                    journalArticleModelImpl.getOriginalClassNameId(),
26090                                                    journalArticleModelImpl.getOriginalClassPK()
26091                                            };
26092    
26093                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
26094                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
26095                                            args);
26096    
26097                                    args = new Object[] {
26098                                                    journalArticleModelImpl.getGroupId(),
26099                                                    journalArticleModelImpl.getClassNameId(),
26100                                                    journalArticleModelImpl.getClassPK()
26101                                            };
26102    
26103                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
26104                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
26105                                            args);
26106                            }
26107    
26108                            if ((journalArticleModelImpl.getColumnBitmask() &
26109                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T.getColumnBitmask()) != 0) {
26110                                    Object[] args = new Object[] {
26111                                                    journalArticleModelImpl.getOriginalGroupId(),
26112                                                    journalArticleModelImpl.getOriginalClassNameId(),
26113                                                    journalArticleModelImpl.getOriginalTemplateId()
26114                                            };
26115    
26116                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args);
26117                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T,
26118                                            args);
26119    
26120                                    args = new Object[] {
26121                                                    journalArticleModelImpl.getGroupId(),
26122                                                    journalArticleModelImpl.getClassNameId(),
26123                                                    journalArticleModelImpl.getTemplateId()
26124                                            };
26125    
26126                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args);
26127                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T,
26128                                            args);
26129                            }
26130    
26131                            if ((journalArticleModelImpl.getColumnBitmask() &
26132                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L.getColumnBitmask()) != 0) {
26133                                    Object[] args = new Object[] {
26134                                                    journalArticleModelImpl.getOriginalGroupId(),
26135                                                    journalArticleModelImpl.getOriginalClassNameId(),
26136                                                    journalArticleModelImpl.getOriginalLayoutUuid()
26137                                            };
26138    
26139                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
26140                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
26141                                            args);
26142    
26143                                    args = new Object[] {
26144                                                    journalArticleModelImpl.getGroupId(),
26145                                                    journalArticleModelImpl.getClassNameId(),
26146                                                    journalArticleModelImpl.getLayoutUuid()
26147                                            };
26148    
26149                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
26150                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
26151                                            args);
26152                            }
26153    
26154                            if ((journalArticleModelImpl.getColumnBitmask() &
26155                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C.getColumnBitmask()) != 0) {
26156                                    Object[] args = new Object[] {
26157                                                    journalArticleModelImpl.getOriginalGroupId(),
26158                                                    journalArticleModelImpl.getOriginalUserId(),
26159                                                    journalArticleModelImpl.getOriginalClassNameId()
26160                                            };
26161    
26162                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_C, args);
26163                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C,
26164                                            args);
26165    
26166                                    args = new Object[] {
26167                                                    journalArticleModelImpl.getGroupId(),
26168                                                    journalArticleModelImpl.getUserId(),
26169                                                    journalArticleModelImpl.getClassNameId()
26170                                            };
26171    
26172                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_C, args);
26173                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C,
26174                                            args);
26175                            }
26176    
26177                            if ((journalArticleModelImpl.getColumnBitmask() &
26178                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST.getColumnBitmask()) != 0) {
26179                                    Object[] args = new Object[] {
26180                                                    journalArticleModelImpl.getOriginalGroupId(),
26181                                                    journalArticleModelImpl.getOriginalArticleId(),
26182                                                    journalArticleModelImpl.getOriginalStatus()
26183                                            };
26184    
26185                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_ST, args);
26186                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST,
26187                                            args);
26188    
26189                                    args = new Object[] {
26190                                                    journalArticleModelImpl.getGroupId(),
26191                                                    journalArticleModelImpl.getArticleId(),
26192                                                    journalArticleModelImpl.getStatus()
26193                                            };
26194    
26195                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_ST, args);
26196                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST,
26197                                            args);
26198                            }
26199    
26200                            if ((journalArticleModelImpl.getColumnBitmask() &
26201                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST.getColumnBitmask()) != 0) {
26202                                    Object[] args = new Object[] {
26203                                                    journalArticleModelImpl.getOriginalGroupId(),
26204                                                    journalArticleModelImpl.getOriginalUrlTitle(),
26205                                                    journalArticleModelImpl.getOriginalStatus()
26206                                            };
26207    
26208                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT_ST, args);
26209                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST,
26210                                            args);
26211    
26212                                    args = new Object[] {
26213                                                    journalArticleModelImpl.getGroupId(),
26214                                                    journalArticleModelImpl.getUrlTitle(),
26215                                                    journalArticleModelImpl.getStatus()
26216                                            };
26217    
26218                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT_ST, args);
26219                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST,
26220                                            args);
26221                            }
26222    
26223                            if ((journalArticleModelImpl.getColumnBitmask() &
26224                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST.getColumnBitmask()) != 0) {
26225                                    Object[] args = new Object[] {
26226                                                    journalArticleModelImpl.getOriginalCompanyId(),
26227                                                    journalArticleModelImpl.getOriginalVersion(),
26228                                                    journalArticleModelImpl.getOriginalStatus()
26229                                            };
26230    
26231                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V_ST, args);
26232                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST,
26233                                            args);
26234    
26235                                    args = new Object[] {
26236                                                    journalArticleModelImpl.getCompanyId(),
26237                                                    journalArticleModelImpl.getVersion(),
26238                                                    journalArticleModelImpl.getStatus()
26239                                            };
26240    
26241                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V_ST, args);
26242                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST,
26243                                            args);
26244                            }
26245                    }
26246    
26247                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
26248                            JournalArticleImpl.class, journalArticle.getPrimaryKey(),
26249                            journalArticle);
26250    
26251                    clearUniqueFindersCache(journalArticle);
26252                    cacheUniqueFindersCache(journalArticle);
26253    
26254                    return journalArticle;
26255            }
26256    
26257            protected JournalArticle toUnwrappedModel(JournalArticle journalArticle) {
26258                    if (journalArticle instanceof JournalArticleImpl) {
26259                            return journalArticle;
26260                    }
26261    
26262                    JournalArticleImpl journalArticleImpl = new JournalArticleImpl();
26263    
26264                    journalArticleImpl.setNew(journalArticle.isNew());
26265                    journalArticleImpl.setPrimaryKey(journalArticle.getPrimaryKey());
26266    
26267                    journalArticleImpl.setUuid(journalArticle.getUuid());
26268                    journalArticleImpl.setId(journalArticle.getId());
26269                    journalArticleImpl.setResourcePrimKey(journalArticle.getResourcePrimKey());
26270                    journalArticleImpl.setGroupId(journalArticle.getGroupId());
26271                    journalArticleImpl.setCompanyId(journalArticle.getCompanyId());
26272                    journalArticleImpl.setUserId(journalArticle.getUserId());
26273                    journalArticleImpl.setUserName(journalArticle.getUserName());
26274                    journalArticleImpl.setCreateDate(journalArticle.getCreateDate());
26275                    journalArticleImpl.setModifiedDate(journalArticle.getModifiedDate());
26276                    journalArticleImpl.setFolderId(journalArticle.getFolderId());
26277                    journalArticleImpl.setClassNameId(journalArticle.getClassNameId());
26278                    journalArticleImpl.setClassPK(journalArticle.getClassPK());
26279                    journalArticleImpl.setArticleId(journalArticle.getArticleId());
26280                    journalArticleImpl.setVersion(journalArticle.getVersion());
26281                    journalArticleImpl.setTitle(journalArticle.getTitle());
26282                    journalArticleImpl.setUrlTitle(journalArticle.getUrlTitle());
26283                    journalArticleImpl.setDescription(journalArticle.getDescription());
26284                    journalArticleImpl.setContent(journalArticle.getContent());
26285                    journalArticleImpl.setType(journalArticle.getType());
26286                    journalArticleImpl.setStructureId(journalArticle.getStructureId());
26287                    journalArticleImpl.setTemplateId(journalArticle.getTemplateId());
26288                    journalArticleImpl.setLayoutUuid(journalArticle.getLayoutUuid());
26289                    journalArticleImpl.setDisplayDate(journalArticle.getDisplayDate());
26290                    journalArticleImpl.setExpirationDate(journalArticle.getExpirationDate());
26291                    journalArticleImpl.setReviewDate(journalArticle.getReviewDate());
26292                    journalArticleImpl.setIndexable(journalArticle.isIndexable());
26293                    journalArticleImpl.setSmallImage(journalArticle.isSmallImage());
26294                    journalArticleImpl.setSmallImageId(journalArticle.getSmallImageId());
26295                    journalArticleImpl.setSmallImageURL(journalArticle.getSmallImageURL());
26296                    journalArticleImpl.setStatus(journalArticle.getStatus());
26297                    journalArticleImpl.setStatusByUserId(journalArticle.getStatusByUserId());
26298                    journalArticleImpl.setStatusByUserName(journalArticle.getStatusByUserName());
26299                    journalArticleImpl.setStatusDate(journalArticle.getStatusDate());
26300    
26301                    return journalArticleImpl;
26302            }
26303    
26304            /**
26305             * Returns the journal article with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
26306             *
26307             * @param primaryKey the primary key of the journal article
26308             * @return the journal article
26309             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
26310             * @throws SystemException if a system exception occurred
26311             */
26312            @Override
26313            public JournalArticle findByPrimaryKey(Serializable primaryKey)
26314                    throws NoSuchArticleException, SystemException {
26315                    JournalArticle journalArticle = fetchByPrimaryKey(primaryKey);
26316    
26317                    if (journalArticle == null) {
26318                            if (_log.isWarnEnabled()) {
26319                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
26320                            }
26321    
26322                            throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
26323                                    primaryKey);
26324                    }
26325    
26326                    return journalArticle;
26327            }
26328    
26329            /**
26330             * Returns the journal article with the primary key or throws a {@link com.liferay.portlet.journal.NoSuchArticleException} if it could not be found.
26331             *
26332             * @param id the primary key of the journal article
26333             * @return the journal article
26334             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
26335             * @throws SystemException if a system exception occurred
26336             */
26337            public JournalArticle findByPrimaryKey(long id)
26338                    throws NoSuchArticleException, SystemException {
26339                    return findByPrimaryKey((Serializable)id);
26340            }
26341    
26342            /**
26343             * Returns the journal article with the primary key or returns <code>null</code> if it could not be found.
26344             *
26345             * @param primaryKey the primary key of the journal article
26346             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
26347             * @throws SystemException if a system exception occurred
26348             */
26349            @Override
26350            public JournalArticle fetchByPrimaryKey(Serializable primaryKey)
26351                    throws SystemException {
26352                    JournalArticle journalArticle = (JournalArticle)EntityCacheUtil.getResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
26353                                    JournalArticleImpl.class, primaryKey);
26354    
26355                    if (journalArticle == _nullJournalArticle) {
26356                            return null;
26357                    }
26358    
26359                    if (journalArticle == null) {
26360                            Session session = null;
26361    
26362                            try {
26363                                    session = openSession();
26364    
26365                                    journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
26366                                                    primaryKey);
26367    
26368                                    if (journalArticle != null) {
26369                                            cacheResult(journalArticle);
26370                                    }
26371                                    else {
26372                                            EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
26373                                                    JournalArticleImpl.class, primaryKey,
26374                                                    _nullJournalArticle);
26375                                    }
26376                            }
26377                            catch (Exception e) {
26378                                    EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
26379                                            JournalArticleImpl.class, primaryKey);
26380    
26381                                    throw processException(e);
26382                            }
26383                            finally {
26384                                    closeSession(session);
26385                            }
26386                    }
26387    
26388                    return journalArticle;
26389            }
26390    
26391            /**
26392             * Returns the journal article with the primary key or returns <code>null</code> if it could not be found.
26393             *
26394             * @param id the primary key of the journal article
26395             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
26396             * @throws SystemException if a system exception occurred
26397             */
26398            public JournalArticle fetchByPrimaryKey(long id) throws SystemException {
26399                    return fetchByPrimaryKey((Serializable)id);
26400            }
26401    
26402            /**
26403             * Returns all the journal articles.
26404             *
26405             * @return the journal articles
26406             * @throws SystemException if a system exception occurred
26407             */
26408            public List<JournalArticle> findAll() throws SystemException {
26409                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
26410            }
26411    
26412            /**
26413             * Returns a range of all the journal articles.
26414             *
26415             * <p>
26416             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
26417             * </p>
26418             *
26419             * @param start the lower bound of the range of journal articles
26420             * @param end the upper bound of the range of journal articles (not inclusive)
26421             * @return the range of journal articles
26422             * @throws SystemException if a system exception occurred
26423             */
26424            public List<JournalArticle> findAll(int start, int end)
26425                    throws SystemException {
26426                    return findAll(start, end, null);
26427            }
26428    
26429            /**
26430             * Returns an ordered range of all the journal articles.
26431             *
26432             * <p>
26433             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
26434             * </p>
26435             *
26436             * @param start the lower bound of the range of journal articles
26437             * @param end the upper bound of the range of journal articles (not inclusive)
26438             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
26439             * @return the ordered range of journal articles
26440             * @throws SystemException if a system exception occurred
26441             */
26442            public List<JournalArticle> findAll(int start, int end,
26443                    OrderByComparator orderByComparator) throws SystemException {
26444                    boolean pagination = true;
26445                    FinderPath finderPath = null;
26446                    Object[] finderArgs = null;
26447    
26448                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
26449                                    (orderByComparator == null)) {
26450                            pagination = false;
26451                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
26452                            finderArgs = FINDER_ARGS_EMPTY;
26453                    }
26454                    else {
26455                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
26456                            finderArgs = new Object[] { start, end, orderByComparator };
26457                    }
26458    
26459                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
26460                                    finderArgs, this);
26461    
26462                    if (list == null) {
26463                            StringBundler query = null;
26464                            String sql = null;
26465    
26466                            if (orderByComparator != null) {
26467                                    query = new StringBundler(2 +
26468                                                    (orderByComparator.getOrderByFields().length * 3));
26469    
26470                                    query.append(_SQL_SELECT_JOURNALARTICLE);
26471    
26472                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
26473                                            orderByComparator);
26474    
26475                                    sql = query.toString();
26476                            }
26477                            else {
26478                                    sql = _SQL_SELECT_JOURNALARTICLE;
26479    
26480                                    if (pagination) {
26481                                            sql = sql.concat(JournalArticleModelImpl.ORDER_BY_JPQL);
26482                                    }
26483                            }
26484    
26485                            Session session = null;
26486    
26487                            try {
26488                                    session = openSession();
26489    
26490                                    Query q = session.createQuery(sql);
26491    
26492                                    if (!pagination) {
26493                                            list = (List<JournalArticle>)QueryUtil.list(q,
26494                                                            getDialect(), start, end, false);
26495    
26496                                            Collections.sort(list);
26497    
26498                                            list = new UnmodifiableList<JournalArticle>(list);
26499                                    }
26500                                    else {
26501                                            list = (List<JournalArticle>)QueryUtil.list(q,
26502                                                            getDialect(), start, end);
26503                                    }
26504    
26505                                    cacheResult(list);
26506    
26507                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
26508                            }
26509                            catch (Exception e) {
26510                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
26511    
26512                                    throw processException(e);
26513                            }
26514                            finally {
26515                                    closeSession(session);
26516                            }
26517                    }
26518    
26519                    return list;
26520            }
26521    
26522            /**
26523             * Removes all the journal articles from the database.
26524             *
26525             * @throws SystemException if a system exception occurred
26526             */
26527            public void removeAll() throws SystemException {
26528                    for (JournalArticle journalArticle : findAll()) {
26529                            remove(journalArticle);
26530                    }
26531            }
26532    
26533            /**
26534             * Returns the number of journal articles.
26535             *
26536             * @return the number of journal articles
26537             * @throws SystemException if a system exception occurred
26538             */
26539            public int countAll() throws SystemException {
26540                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
26541                                    FINDER_ARGS_EMPTY, this);
26542    
26543                    if (count == null) {
26544                            Session session = null;
26545    
26546                            try {
26547                                    session = openSession();
26548    
26549                                    Query q = session.createQuery(_SQL_COUNT_JOURNALARTICLE);
26550    
26551                                    count = (Long)q.uniqueResult();
26552    
26553                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
26554                                            FINDER_ARGS_EMPTY, count);
26555                            }
26556                            catch (Exception e) {
26557                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
26558                                            FINDER_ARGS_EMPTY);
26559    
26560                                    throw processException(e);
26561                            }
26562                            finally {
26563                                    closeSession(session);
26564                            }
26565                    }
26566    
26567                    return count.intValue();
26568            }
26569    
26570            /**
26571             * Initializes the journal article persistence.
26572             */
26573            public void afterPropertiesSet() {
26574                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
26575                                            com.liferay.portal.util.PropsUtil.get(
26576                                                    "value.object.listener.com.liferay.portlet.journal.model.JournalArticle")));
26577    
26578                    if (listenerClassNames.length > 0) {
26579                            try {
26580                                    List<ModelListener<JournalArticle>> listenersList = new ArrayList<ModelListener<JournalArticle>>();
26581    
26582                                    for (String listenerClassName : listenerClassNames) {
26583                                            listenersList.add((ModelListener<JournalArticle>)InstanceFactory.newInstance(
26584                                                            listenerClassName));
26585                                    }
26586    
26587                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
26588                            }
26589                            catch (Exception e) {
26590                                    _log.error(e);
26591                            }
26592                    }
26593            }
26594    
26595            public void destroy() {
26596                    EntityCacheUtil.removeCache(JournalArticleImpl.class.getName());
26597                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
26598                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
26599                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
26600            }
26601    
26602            private static final String _SQL_SELECT_JOURNALARTICLE = "SELECT journalArticle FROM JournalArticle journalArticle";
26603            private static final String _SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT journalArticle FROM JournalArticle journalArticle WHERE ";
26604            private static final String _SQL_COUNT_JOURNALARTICLE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle";
26605            private static final String _SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle WHERE ";
26606            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "journalArticle.resourcePrimKey";
26607            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT DISTINCT {journalArticle.*} FROM JournalArticle journalArticle WHERE ";
26608            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1 =
26609                    "SELECT {JournalArticle.*} FROM (SELECT DISTINCT journalArticle.id_ FROM JournalArticle journalArticle WHERE ";
26610            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2 =
26611                    ") TEMP_TABLE INNER JOIN JournalArticle ON TEMP_TABLE.id_ = JournalArticle.id_";
26612            private static final String _FILTER_SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(DISTINCT journalArticle.id_) AS COUNT_VALUE FROM JournalArticle journalArticle WHERE ";
26613            private static final String _FILTER_ENTITY_ALIAS = "journalArticle";
26614            private static final String _FILTER_ENTITY_TABLE = "JournalArticle";
26615            private static final String _ORDER_BY_ENTITY_ALIAS = "journalArticle.";
26616            private static final String _ORDER_BY_ENTITY_TABLE = "JournalArticle.";
26617            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalArticle exists with the primary key ";
26618            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalArticle exists with the key {";
26619            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
26620            private static Log _log = LogFactoryUtil.getLog(JournalArticlePersistenceImpl.class);
26621            private static JournalArticle _nullJournalArticle = new JournalArticleImpl() {
26622                            @Override
26623                            public Object clone() {
26624                                    return this;
26625                            }
26626    
26627                            @Override
26628                            public CacheModel<JournalArticle> toCacheModel() {
26629                                    return _nullJournalArticleCacheModel;
26630                            }
26631                    };
26632    
26633            private static CacheModel<JournalArticle> _nullJournalArticleCacheModel = new CacheModel<JournalArticle>() {
26634                            public JournalArticle toEntityModel() {
26635                                    return _nullJournalArticle;
26636                            }
26637                    };
26638    }