001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.journal.service.persistence;
016    
017    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
018    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
019    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
020    import com.liferay.portal.kernel.dao.orm.FinderPath;
021    import com.liferay.portal.kernel.dao.orm.Query;
022    import com.liferay.portal.kernel.dao.orm.QueryPos;
023    import com.liferay.portal.kernel.dao.orm.QueryUtil;
024    import com.liferay.portal.kernel.dao.orm.SQLQuery;
025    import com.liferay.portal.kernel.dao.orm.Session;
026    import com.liferay.portal.kernel.exception.SystemException;
027    import com.liferay.portal.kernel.log.Log;
028    import com.liferay.portal.kernel.log.LogFactoryUtil;
029    import com.liferay.portal.kernel.util.ArrayUtil;
030    import com.liferay.portal.kernel.util.CalendarUtil;
031    import com.liferay.portal.kernel.util.GetterUtil;
032    import com.liferay.portal.kernel.util.InstanceFactory;
033    import com.liferay.portal.kernel.util.OrderByComparator;
034    import com.liferay.portal.kernel.util.SetUtil;
035    import com.liferay.portal.kernel.util.StringBundler;
036    import com.liferay.portal.kernel.util.StringPool;
037    import com.liferay.portal.kernel.util.StringUtil;
038    import com.liferay.portal.kernel.util.UnmodifiableList;
039    import com.liferay.portal.kernel.util.Validator;
040    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
041    import com.liferay.portal.model.CacheModel;
042    import com.liferay.portal.model.ModelListener;
043    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
044    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
045    
046    import com.liferay.portlet.journal.NoSuchArticleException;
047    import com.liferay.portlet.journal.model.JournalArticle;
048    import com.liferay.portlet.journal.model.impl.JournalArticleImpl;
049    import com.liferay.portlet.journal.model.impl.JournalArticleModelImpl;
050    
051    import java.io.Serializable;
052    
053    import java.util.ArrayList;
054    import java.util.Collections;
055    import java.util.Date;
056    import java.util.List;
057    import java.util.Set;
058    
059    /**
060     * The persistence implementation for the journal article service.
061     *
062     * <p>
063     * Caching information and settings can be found in <code>portal.properties</code>
064     * </p>
065     *
066     * @author Brian Wing Shun Chan
067     * @see JournalArticlePersistence
068     * @see JournalArticleUtil
069     * @generated
070     */
071    public class JournalArticlePersistenceImpl extends BasePersistenceImpl<JournalArticle>
072            implements JournalArticlePersistence {
073            /*
074             * NOTE FOR DEVELOPERS:
075             *
076             * Never modify or reference this class directly. Always use {@link JournalArticleUtil} to access the journal article persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
077             */
078            public static final String FINDER_CLASS_NAME_ENTITY = JournalArticleImpl.class.getName();
079            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
080                    ".List1";
081            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
082                    ".List2";
083            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
084                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
085                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
086                            "findAll", new String[0]);
087            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
088                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
089                            JournalArticleImpl.class,
090                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
091            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
092                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
093                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
094            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
095                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
096                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
097                            "findByUuid",
098                            new String[] {
099                                    String.class.getName(),
100                                    
101                            Integer.class.getName(), Integer.class.getName(),
102                                    OrderByComparator.class.getName()
103                            });
104            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
105                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
106                            JournalArticleImpl.class,
107                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
108                            new String[] { String.class.getName() },
109                            JournalArticleModelImpl.UUID_COLUMN_BITMASK |
110                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
111                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
112            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
113                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
114                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
115                            new String[] { String.class.getName() });
116    
117            /**
118             * Returns all the journal articles where uuid = &#63;.
119             *
120             * @param uuid the uuid
121             * @return the matching journal articles
122             * @throws SystemException if a system exception occurred
123             */
124            @Override
125            public List<JournalArticle> findByUuid(String uuid)
126                    throws SystemException {
127                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
128            }
129    
130            /**
131             * Returns a range of all the journal articles where uuid = &#63;.
132             *
133             * <p>
134             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
135             * </p>
136             *
137             * @param uuid the uuid
138             * @param start the lower bound of the range of journal articles
139             * @param end the upper bound of the range of journal articles (not inclusive)
140             * @return the range of matching journal articles
141             * @throws SystemException if a system exception occurred
142             */
143            @Override
144            public List<JournalArticle> findByUuid(String uuid, int start, int end)
145                    throws SystemException {
146                    return findByUuid(uuid, start, end, null);
147            }
148    
149            /**
150             * Returns an ordered range of all the journal articles where uuid = &#63;.
151             *
152             * <p>
153             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
154             * </p>
155             *
156             * @param uuid the uuid
157             * @param start the lower bound of the range of journal articles
158             * @param end the upper bound of the range of journal articles (not inclusive)
159             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
160             * @return the ordered range of matching journal articles
161             * @throws SystemException if a system exception occurred
162             */
163            @Override
164            public List<JournalArticle> findByUuid(String uuid, int start, int end,
165                    OrderByComparator orderByComparator) throws SystemException {
166                    boolean pagination = true;
167                    FinderPath finderPath = null;
168                    Object[] finderArgs = null;
169    
170                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
171                                    (orderByComparator == null)) {
172                            pagination = false;
173                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
174                            finderArgs = new Object[] { uuid };
175                    }
176                    else {
177                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
178                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
179                    }
180    
181                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
182                                    finderArgs, this);
183    
184                    if ((list != null) && !list.isEmpty()) {
185                            for (JournalArticle journalArticle : list) {
186                                    if (!Validator.equals(uuid, journalArticle.getUuid())) {
187                                            list = null;
188    
189                                            break;
190                                    }
191                            }
192                    }
193    
194                    if (list == null) {
195                            StringBundler query = null;
196    
197                            if (orderByComparator != null) {
198                                    query = new StringBundler(3 +
199                                                    (orderByComparator.getOrderByFields().length * 3));
200                            }
201                            else {
202                                    query = new StringBundler(3);
203                            }
204    
205                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
206    
207                            boolean bindUuid = false;
208    
209                            if (uuid == null) {
210                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
211                            }
212                            else if (uuid.equals(StringPool.BLANK)) {
213                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
214                            }
215                            else {
216                                    bindUuid = true;
217    
218                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
219                            }
220    
221                            if (orderByComparator != null) {
222                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
223                                            orderByComparator);
224                            }
225                            else
226                             if (pagination) {
227                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
228                            }
229    
230                            String sql = query.toString();
231    
232                            Session session = null;
233    
234                            try {
235                                    session = openSession();
236    
237                                    Query q = session.createQuery(sql);
238    
239                                    QueryPos qPos = QueryPos.getInstance(q);
240    
241                                    if (bindUuid) {
242                                            qPos.add(uuid);
243                                    }
244    
245                                    if (!pagination) {
246                                            list = (List<JournalArticle>)QueryUtil.list(q,
247                                                            getDialect(), start, end, false);
248    
249                                            Collections.sort(list);
250    
251                                            list = new UnmodifiableList<JournalArticle>(list);
252                                    }
253                                    else {
254                                            list = (List<JournalArticle>)QueryUtil.list(q,
255                                                            getDialect(), start, end);
256                                    }
257    
258                                    cacheResult(list);
259    
260                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
261                            }
262                            catch (Exception e) {
263                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
264    
265                                    throw processException(e);
266                            }
267                            finally {
268                                    closeSession(session);
269                            }
270                    }
271    
272                    return list;
273            }
274    
275            /**
276             * Returns the first journal article in the ordered set where uuid = &#63;.
277             *
278             * @param uuid the uuid
279             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
280             * @return the first matching journal article
281             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
282             * @throws SystemException if a system exception occurred
283             */
284            @Override
285            public JournalArticle findByUuid_First(String uuid,
286                    OrderByComparator orderByComparator)
287                    throws NoSuchArticleException, SystemException {
288                    JournalArticle journalArticle = fetchByUuid_First(uuid,
289                                    orderByComparator);
290    
291                    if (journalArticle != null) {
292                            return journalArticle;
293                    }
294    
295                    StringBundler msg = new StringBundler(4);
296    
297                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
298    
299                    msg.append("uuid=");
300                    msg.append(uuid);
301    
302                    msg.append(StringPool.CLOSE_CURLY_BRACE);
303    
304                    throw new NoSuchArticleException(msg.toString());
305            }
306    
307            /**
308             * Returns the first journal article in the ordered set where uuid = &#63;.
309             *
310             * @param uuid the uuid
311             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
312             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
313             * @throws SystemException if a system exception occurred
314             */
315            @Override
316            public JournalArticle fetchByUuid_First(String uuid,
317                    OrderByComparator orderByComparator) throws SystemException {
318                    List<JournalArticle> list = findByUuid(uuid, 0, 1, orderByComparator);
319    
320                    if (!list.isEmpty()) {
321                            return list.get(0);
322                    }
323    
324                    return null;
325            }
326    
327            /**
328             * Returns the last journal article in the ordered set where uuid = &#63;.
329             *
330             * @param uuid the uuid
331             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
332             * @return the last matching journal article
333             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
334             * @throws SystemException if a system exception occurred
335             */
336            @Override
337            public JournalArticle findByUuid_Last(String uuid,
338                    OrderByComparator orderByComparator)
339                    throws NoSuchArticleException, SystemException {
340                    JournalArticle journalArticle = fetchByUuid_Last(uuid, orderByComparator);
341    
342                    if (journalArticle != null) {
343                            return journalArticle;
344                    }
345    
346                    StringBundler msg = new StringBundler(4);
347    
348                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
349    
350                    msg.append("uuid=");
351                    msg.append(uuid);
352    
353                    msg.append(StringPool.CLOSE_CURLY_BRACE);
354    
355                    throw new NoSuchArticleException(msg.toString());
356            }
357    
358            /**
359             * Returns the last journal article in the ordered set where uuid = &#63;.
360             *
361             * @param uuid the uuid
362             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
363             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
364             * @throws SystemException if a system exception occurred
365             */
366            @Override
367            public JournalArticle fetchByUuid_Last(String uuid,
368                    OrderByComparator orderByComparator) throws SystemException {
369                    int count = countByUuid(uuid);
370    
371                    if (count == 0) {
372                            return null;
373                    }
374    
375                    List<JournalArticle> list = findByUuid(uuid, count - 1, count,
376                                    orderByComparator);
377    
378                    if (!list.isEmpty()) {
379                            return list.get(0);
380                    }
381    
382                    return null;
383            }
384    
385            /**
386             * Returns the journal articles before and after the current journal article in the ordered set where uuid = &#63;.
387             *
388             * @param id the primary key of the current journal article
389             * @param uuid the uuid
390             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
391             * @return the previous, current, and next journal article
392             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
393             * @throws SystemException if a system exception occurred
394             */
395            @Override
396            public JournalArticle[] findByUuid_PrevAndNext(long id, String uuid,
397                    OrderByComparator orderByComparator)
398                    throws NoSuchArticleException, SystemException {
399                    JournalArticle journalArticle = findByPrimaryKey(id);
400    
401                    Session session = null;
402    
403                    try {
404                            session = openSession();
405    
406                            JournalArticle[] array = new JournalArticleImpl[3];
407    
408                            array[0] = getByUuid_PrevAndNext(session, journalArticle, uuid,
409                                            orderByComparator, true);
410    
411                            array[1] = journalArticle;
412    
413                            array[2] = getByUuid_PrevAndNext(session, journalArticle, uuid,
414                                            orderByComparator, false);
415    
416                            return array;
417                    }
418                    catch (Exception e) {
419                            throw processException(e);
420                    }
421                    finally {
422                            closeSession(session);
423                    }
424            }
425    
426            protected JournalArticle getByUuid_PrevAndNext(Session session,
427                    JournalArticle journalArticle, String uuid,
428                    OrderByComparator orderByComparator, boolean previous) {
429                    StringBundler query = null;
430    
431                    if (orderByComparator != null) {
432                            query = new StringBundler(6 +
433                                            (orderByComparator.getOrderByFields().length * 6));
434                    }
435                    else {
436                            query = new StringBundler(3);
437                    }
438    
439                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
440    
441                    boolean bindUuid = false;
442    
443                    if (uuid == null) {
444                            query.append(_FINDER_COLUMN_UUID_UUID_1);
445                    }
446                    else if (uuid.equals(StringPool.BLANK)) {
447                            query.append(_FINDER_COLUMN_UUID_UUID_3);
448                    }
449                    else {
450                            bindUuid = true;
451    
452                            query.append(_FINDER_COLUMN_UUID_UUID_2);
453                    }
454    
455                    if (orderByComparator != null) {
456                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
457    
458                            if (orderByConditionFields.length > 0) {
459                                    query.append(WHERE_AND);
460                            }
461    
462                            for (int i = 0; i < orderByConditionFields.length; i++) {
463                                    query.append(_ORDER_BY_ENTITY_ALIAS);
464                                    query.append(orderByConditionFields[i]);
465    
466                                    if ((i + 1) < orderByConditionFields.length) {
467                                            if (orderByComparator.isAscending() ^ previous) {
468                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
469                                            }
470                                            else {
471                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
472                                            }
473                                    }
474                                    else {
475                                            if (orderByComparator.isAscending() ^ previous) {
476                                                    query.append(WHERE_GREATER_THAN);
477                                            }
478                                            else {
479                                                    query.append(WHERE_LESSER_THAN);
480                                            }
481                                    }
482                            }
483    
484                            query.append(ORDER_BY_CLAUSE);
485    
486                            String[] orderByFields = orderByComparator.getOrderByFields();
487    
488                            for (int i = 0; i < orderByFields.length; i++) {
489                                    query.append(_ORDER_BY_ENTITY_ALIAS);
490                                    query.append(orderByFields[i]);
491    
492                                    if ((i + 1) < orderByFields.length) {
493                                            if (orderByComparator.isAscending() ^ previous) {
494                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
495                                            }
496                                            else {
497                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
498                                            }
499                                    }
500                                    else {
501                                            if (orderByComparator.isAscending() ^ previous) {
502                                                    query.append(ORDER_BY_ASC);
503                                            }
504                                            else {
505                                                    query.append(ORDER_BY_DESC);
506                                            }
507                                    }
508                            }
509                    }
510                    else {
511                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
512                    }
513    
514                    String sql = query.toString();
515    
516                    Query q = session.createQuery(sql);
517    
518                    q.setFirstResult(0);
519                    q.setMaxResults(2);
520    
521                    QueryPos qPos = QueryPos.getInstance(q);
522    
523                    if (bindUuid) {
524                            qPos.add(uuid);
525                    }
526    
527                    if (orderByComparator != null) {
528                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
529    
530                            for (Object value : values) {
531                                    qPos.add(value);
532                            }
533                    }
534    
535                    List<JournalArticle> list = q.list();
536    
537                    if (list.size() == 2) {
538                            return list.get(1);
539                    }
540                    else {
541                            return null;
542                    }
543            }
544    
545            /**
546             * Removes all the journal articles where uuid = &#63; from the database.
547             *
548             * @param uuid the uuid
549             * @throws SystemException if a system exception occurred
550             */
551            @Override
552            public void removeByUuid(String uuid) throws SystemException {
553                    for (JournalArticle journalArticle : findByUuid(uuid,
554                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
555                            remove(journalArticle);
556                    }
557            }
558    
559            /**
560             * Returns the number of journal articles where uuid = &#63;.
561             *
562             * @param uuid the uuid
563             * @return the number of matching journal articles
564             * @throws SystemException if a system exception occurred
565             */
566            @Override
567            public int countByUuid(String uuid) throws SystemException {
568                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
569    
570                    Object[] finderArgs = new Object[] { uuid };
571    
572                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
573                                    this);
574    
575                    if (count == null) {
576                            StringBundler query = new StringBundler(2);
577    
578                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
579    
580                            boolean bindUuid = false;
581    
582                            if (uuid == null) {
583                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
584                            }
585                            else if (uuid.equals(StringPool.BLANK)) {
586                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
587                            }
588                            else {
589                                    bindUuid = true;
590    
591                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
592                            }
593    
594                            String sql = query.toString();
595    
596                            Session session = null;
597    
598                            try {
599                                    session = openSession();
600    
601                                    Query q = session.createQuery(sql);
602    
603                                    QueryPos qPos = QueryPos.getInstance(q);
604    
605                                    if (bindUuid) {
606                                            qPos.add(uuid);
607                                    }
608    
609                                    count = (Long)q.uniqueResult();
610    
611                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
612                            }
613                            catch (Exception e) {
614                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
615    
616                                    throw processException(e);
617                            }
618                            finally {
619                                    closeSession(session);
620                            }
621                    }
622    
623                    return count.intValue();
624            }
625    
626            private static final String _FINDER_COLUMN_UUID_UUID_1 = "journalArticle.uuid IS NULL";
627            private static final String _FINDER_COLUMN_UUID_UUID_2 = "journalArticle.uuid = ?";
628            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = '')";
629            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
630                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
631                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY,
632                            "fetchByUUID_G",
633                            new String[] { String.class.getName(), Long.class.getName() },
634                            JournalArticleModelImpl.UUID_COLUMN_BITMASK |
635                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK);
636            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
637                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
638                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
639                            new String[] { String.class.getName(), Long.class.getName() });
640    
641            /**
642             * Returns the journal article where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portlet.journal.NoSuchArticleException} if it could not be found.
643             *
644             * @param uuid the uuid
645             * @param groupId the group ID
646             * @return the matching journal article
647             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
648             * @throws SystemException if a system exception occurred
649             */
650            @Override
651            public JournalArticle findByUUID_G(String uuid, long groupId)
652                    throws NoSuchArticleException, SystemException {
653                    JournalArticle journalArticle = fetchByUUID_G(uuid, groupId);
654    
655                    if (journalArticle == null) {
656                            StringBundler msg = new StringBundler(6);
657    
658                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
659    
660                            msg.append("uuid=");
661                            msg.append(uuid);
662    
663                            msg.append(", groupId=");
664                            msg.append(groupId);
665    
666                            msg.append(StringPool.CLOSE_CURLY_BRACE);
667    
668                            if (_log.isWarnEnabled()) {
669                                    _log.warn(msg.toString());
670                            }
671    
672                            throw new NoSuchArticleException(msg.toString());
673                    }
674    
675                    return journalArticle;
676            }
677    
678            /**
679             * Returns the journal article where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
680             *
681             * @param uuid the uuid
682             * @param groupId the group ID
683             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
684             * @throws SystemException if a system exception occurred
685             */
686            @Override
687            public JournalArticle fetchByUUID_G(String uuid, long groupId)
688                    throws SystemException {
689                    return fetchByUUID_G(uuid, groupId, true);
690            }
691    
692            /**
693             * Returns the journal article where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
694             *
695             * @param uuid the uuid
696             * @param groupId the group ID
697             * @param retrieveFromCache whether to use the finder cache
698             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
699             * @throws SystemException if a system exception occurred
700             */
701            @Override
702            public JournalArticle fetchByUUID_G(String uuid, long groupId,
703                    boolean retrieveFromCache) throws SystemException {
704                    Object[] finderArgs = new Object[] { uuid, groupId };
705    
706                    Object result = null;
707    
708                    if (retrieveFromCache) {
709                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
710                                            finderArgs, this);
711                    }
712    
713                    if (result instanceof JournalArticle) {
714                            JournalArticle journalArticle = (JournalArticle)result;
715    
716                            if (!Validator.equals(uuid, journalArticle.getUuid()) ||
717                                            (groupId != journalArticle.getGroupId())) {
718                                    result = null;
719                            }
720                    }
721    
722                    if (result == null) {
723                            StringBundler query = new StringBundler(4);
724    
725                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
726    
727                            boolean bindUuid = false;
728    
729                            if (uuid == null) {
730                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
731                            }
732                            else if (uuid.equals(StringPool.BLANK)) {
733                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
734                            }
735                            else {
736                                    bindUuid = true;
737    
738                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
739                            }
740    
741                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
742    
743                            String sql = query.toString();
744    
745                            Session session = null;
746    
747                            try {
748                                    session = openSession();
749    
750                                    Query q = session.createQuery(sql);
751    
752                                    QueryPos qPos = QueryPos.getInstance(q);
753    
754                                    if (bindUuid) {
755                                            qPos.add(uuid);
756                                    }
757    
758                                    qPos.add(groupId);
759    
760                                    List<JournalArticle> list = q.list();
761    
762                                    if (list.isEmpty()) {
763                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
764                                                    finderArgs, list);
765                                    }
766                                    else {
767                                            JournalArticle journalArticle = list.get(0);
768    
769                                            result = journalArticle;
770    
771                                            cacheResult(journalArticle);
772    
773                                            if ((journalArticle.getUuid() == null) ||
774                                                            !journalArticle.getUuid().equals(uuid) ||
775                                                            (journalArticle.getGroupId() != groupId)) {
776                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
777                                                            finderArgs, journalArticle);
778                                            }
779                                    }
780                            }
781                            catch (Exception e) {
782                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
783                                            finderArgs);
784    
785                                    throw processException(e);
786                            }
787                            finally {
788                                    closeSession(session);
789                            }
790                    }
791    
792                    if (result instanceof List<?>) {
793                            return null;
794                    }
795                    else {
796                            return (JournalArticle)result;
797                    }
798            }
799    
800            /**
801             * Removes the journal article where uuid = &#63; and groupId = &#63; from the database.
802             *
803             * @param uuid the uuid
804             * @param groupId the group ID
805             * @return the journal article that was removed
806             * @throws SystemException if a system exception occurred
807             */
808            @Override
809            public JournalArticle removeByUUID_G(String uuid, long groupId)
810                    throws NoSuchArticleException, SystemException {
811                    JournalArticle journalArticle = findByUUID_G(uuid, groupId);
812    
813                    return remove(journalArticle);
814            }
815    
816            /**
817             * Returns the number of journal articles where uuid = &#63; and groupId = &#63;.
818             *
819             * @param uuid the uuid
820             * @param groupId the group ID
821             * @return the number of matching journal articles
822             * @throws SystemException if a system exception occurred
823             */
824            @Override
825            public int countByUUID_G(String uuid, long groupId)
826                    throws SystemException {
827                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
828    
829                    Object[] finderArgs = new Object[] { uuid, groupId };
830    
831                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
832                                    this);
833    
834                    if (count == null) {
835                            StringBundler query = new StringBundler(3);
836    
837                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
838    
839                            boolean bindUuid = false;
840    
841                            if (uuid == null) {
842                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
843                            }
844                            else if (uuid.equals(StringPool.BLANK)) {
845                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
846                            }
847                            else {
848                                    bindUuid = true;
849    
850                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
851                            }
852    
853                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
854    
855                            String sql = query.toString();
856    
857                            Session session = null;
858    
859                            try {
860                                    session = openSession();
861    
862                                    Query q = session.createQuery(sql);
863    
864                                    QueryPos qPos = QueryPos.getInstance(q);
865    
866                                    if (bindUuid) {
867                                            qPos.add(uuid);
868                                    }
869    
870                                    qPos.add(groupId);
871    
872                                    count = (Long)q.uniqueResult();
873    
874                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
875                            }
876                            catch (Exception e) {
877                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
878    
879                                    throw processException(e);
880                            }
881                            finally {
882                                    closeSession(session);
883                            }
884                    }
885    
886                    return count.intValue();
887            }
888    
889            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "journalArticle.uuid IS NULL AND ";
890            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "journalArticle.uuid = ? AND ";
891            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = '') AND ";
892            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "journalArticle.groupId = ?";
893            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
894                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
895                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
896                            "findByUuid_C",
897                            new String[] {
898                                    String.class.getName(), Long.class.getName(),
899                                    
900                            Integer.class.getName(), Integer.class.getName(),
901                                    OrderByComparator.class.getName()
902                            });
903            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
904                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
905                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
906                            JournalArticleImpl.class,
907                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
908                            new String[] { String.class.getName(), Long.class.getName() },
909                            JournalArticleModelImpl.UUID_COLUMN_BITMASK |
910                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
911                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
912                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
913            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
914                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
915                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
916                            new String[] { String.class.getName(), Long.class.getName() });
917    
918            /**
919             * Returns all the journal articles where uuid = &#63; and companyId = &#63;.
920             *
921             * @param uuid the uuid
922             * @param companyId the company ID
923             * @return the matching journal articles
924             * @throws SystemException if a system exception occurred
925             */
926            @Override
927            public List<JournalArticle> findByUuid_C(String uuid, long companyId)
928                    throws SystemException {
929                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
930                            QueryUtil.ALL_POS, null);
931            }
932    
933            /**
934             * Returns a range of all the journal articles where uuid = &#63; and companyId = &#63;.
935             *
936             * <p>
937             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
938             * </p>
939             *
940             * @param uuid the uuid
941             * @param companyId the company ID
942             * @param start the lower bound of the range of journal articles
943             * @param end the upper bound of the range of journal articles (not inclusive)
944             * @return the range of matching journal articles
945             * @throws SystemException if a system exception occurred
946             */
947            @Override
948            public List<JournalArticle> findByUuid_C(String uuid, long companyId,
949                    int start, int end) throws SystemException {
950                    return findByUuid_C(uuid, companyId, start, end, null);
951            }
952    
953            /**
954             * Returns an ordered range of all the journal articles where uuid = &#63; and companyId = &#63;.
955             *
956             * <p>
957             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
958             * </p>
959             *
960             * @param uuid the uuid
961             * @param companyId the company ID
962             * @param start the lower bound of the range of journal articles
963             * @param end the upper bound of the range of journal articles (not inclusive)
964             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
965             * @return the ordered range of matching journal articles
966             * @throws SystemException if a system exception occurred
967             */
968            @Override
969            public List<JournalArticle> findByUuid_C(String uuid, long companyId,
970                    int start, int end, OrderByComparator orderByComparator)
971                    throws SystemException {
972                    boolean pagination = true;
973                    FinderPath finderPath = null;
974                    Object[] finderArgs = null;
975    
976                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
977                                    (orderByComparator == null)) {
978                            pagination = false;
979                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
980                            finderArgs = new Object[] { uuid, companyId };
981                    }
982                    else {
983                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
984                            finderArgs = new Object[] {
985                                            uuid, companyId,
986                                            
987                                            start, end, orderByComparator
988                                    };
989                    }
990    
991                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
992                                    finderArgs, this);
993    
994                    if ((list != null) && !list.isEmpty()) {
995                            for (JournalArticle journalArticle : list) {
996                                    if (!Validator.equals(uuid, journalArticle.getUuid()) ||
997                                                    (companyId != journalArticle.getCompanyId())) {
998                                            list = null;
999    
1000                                            break;
1001                                    }
1002                            }
1003                    }
1004    
1005                    if (list == null) {
1006                            StringBundler query = null;
1007    
1008                            if (orderByComparator != null) {
1009                                    query = new StringBundler(4 +
1010                                                    (orderByComparator.getOrderByFields().length * 3));
1011                            }
1012                            else {
1013                                    query = new StringBundler(4);
1014                            }
1015    
1016                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1017    
1018                            boolean bindUuid = false;
1019    
1020                            if (uuid == null) {
1021                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1022                            }
1023                            else if (uuid.equals(StringPool.BLANK)) {
1024                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1025                            }
1026                            else {
1027                                    bindUuid = true;
1028    
1029                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1030                            }
1031    
1032                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1033    
1034                            if (orderByComparator != null) {
1035                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1036                                            orderByComparator);
1037                            }
1038                            else
1039                             if (pagination) {
1040                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1041                            }
1042    
1043                            String sql = query.toString();
1044    
1045                            Session session = null;
1046    
1047                            try {
1048                                    session = openSession();
1049    
1050                                    Query q = session.createQuery(sql);
1051    
1052                                    QueryPos qPos = QueryPos.getInstance(q);
1053    
1054                                    if (bindUuid) {
1055                                            qPos.add(uuid);
1056                                    }
1057    
1058                                    qPos.add(companyId);
1059    
1060                                    if (!pagination) {
1061                                            list = (List<JournalArticle>)QueryUtil.list(q,
1062                                                            getDialect(), start, end, false);
1063    
1064                                            Collections.sort(list);
1065    
1066                                            list = new UnmodifiableList<JournalArticle>(list);
1067                                    }
1068                                    else {
1069                                            list = (List<JournalArticle>)QueryUtil.list(q,
1070                                                            getDialect(), start, end);
1071                                    }
1072    
1073                                    cacheResult(list);
1074    
1075                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1076                            }
1077                            catch (Exception e) {
1078                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1079    
1080                                    throw processException(e);
1081                            }
1082                            finally {
1083                                    closeSession(session);
1084                            }
1085                    }
1086    
1087                    return list;
1088            }
1089    
1090            /**
1091             * Returns the first journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1092             *
1093             * @param uuid the uuid
1094             * @param companyId the company ID
1095             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1096             * @return the first matching journal article
1097             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1098             * @throws SystemException if a system exception occurred
1099             */
1100            @Override
1101            public JournalArticle findByUuid_C_First(String uuid, long companyId,
1102                    OrderByComparator orderByComparator)
1103                    throws NoSuchArticleException, SystemException {
1104                    JournalArticle journalArticle = fetchByUuid_C_First(uuid, companyId,
1105                                    orderByComparator);
1106    
1107                    if (journalArticle != null) {
1108                            return journalArticle;
1109                    }
1110    
1111                    StringBundler msg = new StringBundler(6);
1112    
1113                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1114    
1115                    msg.append("uuid=");
1116                    msg.append(uuid);
1117    
1118                    msg.append(", companyId=");
1119                    msg.append(companyId);
1120    
1121                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1122    
1123                    throw new NoSuchArticleException(msg.toString());
1124            }
1125    
1126            /**
1127             * Returns the first journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1128             *
1129             * @param uuid the uuid
1130             * @param companyId the company ID
1131             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1132             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
1133             * @throws SystemException if a system exception occurred
1134             */
1135            @Override
1136            public JournalArticle fetchByUuid_C_First(String uuid, long companyId,
1137                    OrderByComparator orderByComparator) throws SystemException {
1138                    List<JournalArticle> list = findByUuid_C(uuid, companyId, 0, 1,
1139                                    orderByComparator);
1140    
1141                    if (!list.isEmpty()) {
1142                            return list.get(0);
1143                    }
1144    
1145                    return null;
1146            }
1147    
1148            /**
1149             * Returns the last journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1150             *
1151             * @param uuid the uuid
1152             * @param companyId the company ID
1153             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1154             * @return the last matching journal article
1155             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1156             * @throws SystemException if a system exception occurred
1157             */
1158            @Override
1159            public JournalArticle findByUuid_C_Last(String uuid, long companyId,
1160                    OrderByComparator orderByComparator)
1161                    throws NoSuchArticleException, SystemException {
1162                    JournalArticle journalArticle = fetchByUuid_C_Last(uuid, companyId,
1163                                    orderByComparator);
1164    
1165                    if (journalArticle != null) {
1166                            return journalArticle;
1167                    }
1168    
1169                    StringBundler msg = new StringBundler(6);
1170    
1171                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1172    
1173                    msg.append("uuid=");
1174                    msg.append(uuid);
1175    
1176                    msg.append(", companyId=");
1177                    msg.append(companyId);
1178    
1179                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1180    
1181                    throw new NoSuchArticleException(msg.toString());
1182            }
1183    
1184            /**
1185             * Returns the last journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1186             *
1187             * @param uuid the uuid
1188             * @param companyId the company ID
1189             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1190             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
1191             * @throws SystemException if a system exception occurred
1192             */
1193            @Override
1194            public JournalArticle fetchByUuid_C_Last(String uuid, long companyId,
1195                    OrderByComparator orderByComparator) throws SystemException {
1196                    int count = countByUuid_C(uuid, companyId);
1197    
1198                    if (count == 0) {
1199                            return null;
1200                    }
1201    
1202                    List<JournalArticle> list = findByUuid_C(uuid, companyId, count - 1,
1203                                    count, orderByComparator);
1204    
1205                    if (!list.isEmpty()) {
1206                            return list.get(0);
1207                    }
1208    
1209                    return null;
1210            }
1211    
1212            /**
1213             * Returns the journal articles before and after the current journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1214             *
1215             * @param id the primary key of the current journal article
1216             * @param uuid the uuid
1217             * @param companyId the company ID
1218             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1219             * @return the previous, current, and next journal article
1220             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
1221             * @throws SystemException if a system exception occurred
1222             */
1223            @Override
1224            public JournalArticle[] findByUuid_C_PrevAndNext(long id, String uuid,
1225                    long companyId, OrderByComparator orderByComparator)
1226                    throws NoSuchArticleException, SystemException {
1227                    JournalArticle journalArticle = findByPrimaryKey(id);
1228    
1229                    Session session = null;
1230    
1231                    try {
1232                            session = openSession();
1233    
1234                            JournalArticle[] array = new JournalArticleImpl[3];
1235    
1236                            array[0] = getByUuid_C_PrevAndNext(session, journalArticle, uuid,
1237                                            companyId, orderByComparator, true);
1238    
1239                            array[1] = journalArticle;
1240    
1241                            array[2] = getByUuid_C_PrevAndNext(session, journalArticle, uuid,
1242                                            companyId, orderByComparator, false);
1243    
1244                            return array;
1245                    }
1246                    catch (Exception e) {
1247                            throw processException(e);
1248                    }
1249                    finally {
1250                            closeSession(session);
1251                    }
1252            }
1253    
1254            protected JournalArticle getByUuid_C_PrevAndNext(Session session,
1255                    JournalArticle journalArticle, String uuid, long companyId,
1256                    OrderByComparator orderByComparator, boolean previous) {
1257                    StringBundler query = null;
1258    
1259                    if (orderByComparator != null) {
1260                            query = new StringBundler(6 +
1261                                            (orderByComparator.getOrderByFields().length * 6));
1262                    }
1263                    else {
1264                            query = new StringBundler(3);
1265                    }
1266    
1267                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1268    
1269                    boolean bindUuid = false;
1270    
1271                    if (uuid == null) {
1272                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1273                    }
1274                    else if (uuid.equals(StringPool.BLANK)) {
1275                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1276                    }
1277                    else {
1278                            bindUuid = true;
1279    
1280                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1281                    }
1282    
1283                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1284    
1285                    if (orderByComparator != null) {
1286                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1287    
1288                            if (orderByConditionFields.length > 0) {
1289                                    query.append(WHERE_AND);
1290                            }
1291    
1292                            for (int i = 0; i < orderByConditionFields.length; i++) {
1293                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1294                                    query.append(orderByConditionFields[i]);
1295    
1296                                    if ((i + 1) < orderByConditionFields.length) {
1297                                            if (orderByComparator.isAscending() ^ previous) {
1298                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1299                                            }
1300                                            else {
1301                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1302                                            }
1303                                    }
1304                                    else {
1305                                            if (orderByComparator.isAscending() ^ previous) {
1306                                                    query.append(WHERE_GREATER_THAN);
1307                                            }
1308                                            else {
1309                                                    query.append(WHERE_LESSER_THAN);
1310                                            }
1311                                    }
1312                            }
1313    
1314                            query.append(ORDER_BY_CLAUSE);
1315    
1316                            String[] orderByFields = orderByComparator.getOrderByFields();
1317    
1318                            for (int i = 0; i < orderByFields.length; i++) {
1319                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1320                                    query.append(orderByFields[i]);
1321    
1322                                    if ((i + 1) < orderByFields.length) {
1323                                            if (orderByComparator.isAscending() ^ previous) {
1324                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1325                                            }
1326                                            else {
1327                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1328                                            }
1329                                    }
1330                                    else {
1331                                            if (orderByComparator.isAscending() ^ previous) {
1332                                                    query.append(ORDER_BY_ASC);
1333                                            }
1334                                            else {
1335                                                    query.append(ORDER_BY_DESC);
1336                                            }
1337                                    }
1338                            }
1339                    }
1340                    else {
1341                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1342                    }
1343    
1344                    String sql = query.toString();
1345    
1346                    Query q = session.createQuery(sql);
1347    
1348                    q.setFirstResult(0);
1349                    q.setMaxResults(2);
1350    
1351                    QueryPos qPos = QueryPos.getInstance(q);
1352    
1353                    if (bindUuid) {
1354                            qPos.add(uuid);
1355                    }
1356    
1357                    qPos.add(companyId);
1358    
1359                    if (orderByComparator != null) {
1360                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
1361    
1362                            for (Object value : values) {
1363                                    qPos.add(value);
1364                            }
1365                    }
1366    
1367                    List<JournalArticle> list = q.list();
1368    
1369                    if (list.size() == 2) {
1370                            return list.get(1);
1371                    }
1372                    else {
1373                            return null;
1374                    }
1375            }
1376    
1377            /**
1378             * Removes all the journal articles where uuid = &#63; and companyId = &#63; from the database.
1379             *
1380             * @param uuid the uuid
1381             * @param companyId the company ID
1382             * @throws SystemException if a system exception occurred
1383             */
1384            @Override
1385            public void removeByUuid_C(String uuid, long companyId)
1386                    throws SystemException {
1387                    for (JournalArticle journalArticle : findByUuid_C(uuid, companyId,
1388                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1389                            remove(journalArticle);
1390                    }
1391            }
1392    
1393            /**
1394             * Returns the number of journal articles where uuid = &#63; and companyId = &#63;.
1395             *
1396             * @param uuid the uuid
1397             * @param companyId the company ID
1398             * @return the number of matching journal articles
1399             * @throws SystemException if a system exception occurred
1400             */
1401            @Override
1402            public int countByUuid_C(String uuid, long companyId)
1403                    throws SystemException {
1404                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1405    
1406                    Object[] finderArgs = new Object[] { uuid, companyId };
1407    
1408                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1409                                    this);
1410    
1411                    if (count == null) {
1412                            StringBundler query = new StringBundler(3);
1413    
1414                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
1415    
1416                            boolean bindUuid = false;
1417    
1418                            if (uuid == null) {
1419                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1420                            }
1421                            else if (uuid.equals(StringPool.BLANK)) {
1422                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1423                            }
1424                            else {
1425                                    bindUuid = true;
1426    
1427                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1428                            }
1429    
1430                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1431    
1432                            String sql = query.toString();
1433    
1434                            Session session = null;
1435    
1436                            try {
1437                                    session = openSession();
1438    
1439                                    Query q = session.createQuery(sql);
1440    
1441                                    QueryPos qPos = QueryPos.getInstance(q);
1442    
1443                                    if (bindUuid) {
1444                                            qPos.add(uuid);
1445                                    }
1446    
1447                                    qPos.add(companyId);
1448    
1449                                    count = (Long)q.uniqueResult();
1450    
1451                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1452                            }
1453                            catch (Exception e) {
1454                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1455    
1456                                    throw processException(e);
1457                            }
1458                            finally {
1459                                    closeSession(session);
1460                            }
1461                    }
1462    
1463                    return count.intValue();
1464            }
1465    
1466            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "journalArticle.uuid IS NULL AND ";
1467            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "journalArticle.uuid = ? AND ";
1468            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = '') AND ";
1469            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "journalArticle.companyId = ?";
1470            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEPRIMKEY =
1471                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1472                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
1473                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1474                            "findByResourcePrimKey",
1475                            new String[] {
1476                                    Long.class.getName(),
1477                                    
1478                            Integer.class.getName(), Integer.class.getName(),
1479                                    OrderByComparator.class.getName()
1480                            });
1481            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY =
1482                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1483                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
1484                            JournalArticleImpl.class,
1485                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByResourcePrimKey",
1486                            new String[] { Long.class.getName() },
1487                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
1488                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
1489                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
1490            public static final FinderPath FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1491                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
1492                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
1493                            "countByResourcePrimKey", new String[] { Long.class.getName() });
1494    
1495            /**
1496             * Returns all the journal articles where resourcePrimKey = &#63;.
1497             *
1498             * @param resourcePrimKey the resource prim key
1499             * @return the matching journal articles
1500             * @throws SystemException if a system exception occurred
1501             */
1502            @Override
1503            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey)
1504                    throws SystemException {
1505                    return findByResourcePrimKey(resourcePrimKey, QueryUtil.ALL_POS,
1506                            QueryUtil.ALL_POS, null);
1507            }
1508    
1509            /**
1510             * Returns a range of all the journal articles where resourcePrimKey = &#63;.
1511             *
1512             * <p>
1513             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1514             * </p>
1515             *
1516             * @param resourcePrimKey the resource prim key
1517             * @param start the lower bound of the range of journal articles
1518             * @param end the upper bound of the range of journal articles (not inclusive)
1519             * @return the range of matching journal articles
1520             * @throws SystemException if a system exception occurred
1521             */
1522            @Override
1523            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey,
1524                    int start, int end) throws SystemException {
1525                    return findByResourcePrimKey(resourcePrimKey, start, end, null);
1526            }
1527    
1528            /**
1529             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63;.
1530             *
1531             * <p>
1532             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1533             * </p>
1534             *
1535             * @param resourcePrimKey the resource prim key
1536             * @param start the lower bound of the range of journal articles
1537             * @param end the upper bound of the range of journal articles (not inclusive)
1538             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1539             * @return the ordered range of matching journal articles
1540             * @throws SystemException if a system exception occurred
1541             */
1542            @Override
1543            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey,
1544                    int start, int end, OrderByComparator orderByComparator)
1545                    throws SystemException {
1546                    boolean pagination = true;
1547                    FinderPath finderPath = null;
1548                    Object[] finderArgs = null;
1549    
1550                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1551                                    (orderByComparator == null)) {
1552                            pagination = false;
1553                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY;
1554                            finderArgs = new Object[] { resourcePrimKey };
1555                    }
1556                    else {
1557                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEPRIMKEY;
1558                            finderArgs = new Object[] {
1559                                            resourcePrimKey,
1560                                            
1561                                            start, end, orderByComparator
1562                                    };
1563                    }
1564    
1565                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
1566                                    finderArgs, this);
1567    
1568                    if ((list != null) && !list.isEmpty()) {
1569                            for (JournalArticle journalArticle : list) {
1570                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey())) {
1571                                            list = null;
1572    
1573                                            break;
1574                                    }
1575                            }
1576                    }
1577    
1578                    if (list == null) {
1579                            StringBundler query = null;
1580    
1581                            if (orderByComparator != null) {
1582                                    query = new StringBundler(3 +
1583                                                    (orderByComparator.getOrderByFields().length * 3));
1584                            }
1585                            else {
1586                                    query = new StringBundler(3);
1587                            }
1588    
1589                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1590    
1591                            query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
1592    
1593                            if (orderByComparator != null) {
1594                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1595                                            orderByComparator);
1596                            }
1597                            else
1598                             if (pagination) {
1599                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1600                            }
1601    
1602                            String sql = query.toString();
1603    
1604                            Session session = null;
1605    
1606                            try {
1607                                    session = openSession();
1608    
1609                                    Query q = session.createQuery(sql);
1610    
1611                                    QueryPos qPos = QueryPos.getInstance(q);
1612    
1613                                    qPos.add(resourcePrimKey);
1614    
1615                                    if (!pagination) {
1616                                            list = (List<JournalArticle>)QueryUtil.list(q,
1617                                                            getDialect(), start, end, false);
1618    
1619                                            Collections.sort(list);
1620    
1621                                            list = new UnmodifiableList<JournalArticle>(list);
1622                                    }
1623                                    else {
1624                                            list = (List<JournalArticle>)QueryUtil.list(q,
1625                                                            getDialect(), start, end);
1626                                    }
1627    
1628                                    cacheResult(list);
1629    
1630                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1631                            }
1632                            catch (Exception e) {
1633                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1634    
1635                                    throw processException(e);
1636                            }
1637                            finally {
1638                                    closeSession(session);
1639                            }
1640                    }
1641    
1642                    return list;
1643            }
1644    
1645            /**
1646             * Returns the first journal article in the ordered set where resourcePrimKey = &#63;.
1647             *
1648             * @param resourcePrimKey the resource prim key
1649             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1650             * @return the first matching journal article
1651             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1652             * @throws SystemException if a system exception occurred
1653             */
1654            @Override
1655            public JournalArticle findByResourcePrimKey_First(long resourcePrimKey,
1656                    OrderByComparator orderByComparator)
1657                    throws NoSuchArticleException, SystemException {
1658                    JournalArticle journalArticle = fetchByResourcePrimKey_First(resourcePrimKey,
1659                                    orderByComparator);
1660    
1661                    if (journalArticle != null) {
1662                            return journalArticle;
1663                    }
1664    
1665                    StringBundler msg = new StringBundler(4);
1666    
1667                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1668    
1669                    msg.append("resourcePrimKey=");
1670                    msg.append(resourcePrimKey);
1671    
1672                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1673    
1674                    throw new NoSuchArticleException(msg.toString());
1675            }
1676    
1677            /**
1678             * Returns the first journal article in the ordered set where resourcePrimKey = &#63;.
1679             *
1680             * @param resourcePrimKey the resource prim key
1681             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1682             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
1683             * @throws SystemException if a system exception occurred
1684             */
1685            @Override
1686            public JournalArticle fetchByResourcePrimKey_First(long resourcePrimKey,
1687                    OrderByComparator orderByComparator) throws SystemException {
1688                    List<JournalArticle> list = findByResourcePrimKey(resourcePrimKey, 0,
1689                                    1, orderByComparator);
1690    
1691                    if (!list.isEmpty()) {
1692                            return list.get(0);
1693                    }
1694    
1695                    return null;
1696            }
1697    
1698            /**
1699             * Returns the last journal article in the ordered set where resourcePrimKey = &#63;.
1700             *
1701             * @param resourcePrimKey the resource prim key
1702             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1703             * @return the last matching journal article
1704             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1705             * @throws SystemException if a system exception occurred
1706             */
1707            @Override
1708            public JournalArticle findByResourcePrimKey_Last(long resourcePrimKey,
1709                    OrderByComparator orderByComparator)
1710                    throws NoSuchArticleException, SystemException {
1711                    JournalArticle journalArticle = fetchByResourcePrimKey_Last(resourcePrimKey,
1712                                    orderByComparator);
1713    
1714                    if (journalArticle != null) {
1715                            return journalArticle;
1716                    }
1717    
1718                    StringBundler msg = new StringBundler(4);
1719    
1720                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1721    
1722                    msg.append("resourcePrimKey=");
1723                    msg.append(resourcePrimKey);
1724    
1725                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1726    
1727                    throw new NoSuchArticleException(msg.toString());
1728            }
1729    
1730            /**
1731             * Returns the last journal article in the ordered set where resourcePrimKey = &#63;.
1732             *
1733             * @param resourcePrimKey the resource prim key
1734             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1735             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
1736             * @throws SystemException if a system exception occurred
1737             */
1738            @Override
1739            public JournalArticle fetchByResourcePrimKey_Last(long resourcePrimKey,
1740                    OrderByComparator orderByComparator) throws SystemException {
1741                    int count = countByResourcePrimKey(resourcePrimKey);
1742    
1743                    if (count == 0) {
1744                            return null;
1745                    }
1746    
1747                    List<JournalArticle> list = findByResourcePrimKey(resourcePrimKey,
1748                                    count - 1, count, orderByComparator);
1749    
1750                    if (!list.isEmpty()) {
1751                            return list.get(0);
1752                    }
1753    
1754                    return null;
1755            }
1756    
1757            /**
1758             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63;.
1759             *
1760             * @param id the primary key of the current journal article
1761             * @param resourcePrimKey the resource prim key
1762             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1763             * @return the previous, current, and next journal article
1764             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
1765             * @throws SystemException if a system exception occurred
1766             */
1767            @Override
1768            public JournalArticle[] findByResourcePrimKey_PrevAndNext(long id,
1769                    long resourcePrimKey, OrderByComparator orderByComparator)
1770                    throws NoSuchArticleException, SystemException {
1771                    JournalArticle journalArticle = findByPrimaryKey(id);
1772    
1773                    Session session = null;
1774    
1775                    try {
1776                            session = openSession();
1777    
1778                            JournalArticle[] array = new JournalArticleImpl[3];
1779    
1780                            array[0] = getByResourcePrimKey_PrevAndNext(session,
1781                                            journalArticle, resourcePrimKey, orderByComparator, true);
1782    
1783                            array[1] = journalArticle;
1784    
1785                            array[2] = getByResourcePrimKey_PrevAndNext(session,
1786                                            journalArticle, resourcePrimKey, orderByComparator, false);
1787    
1788                            return array;
1789                    }
1790                    catch (Exception e) {
1791                            throw processException(e);
1792                    }
1793                    finally {
1794                            closeSession(session);
1795                    }
1796            }
1797    
1798            protected JournalArticle getByResourcePrimKey_PrevAndNext(Session session,
1799                    JournalArticle journalArticle, long resourcePrimKey,
1800                    OrderByComparator orderByComparator, boolean previous) {
1801                    StringBundler query = null;
1802    
1803                    if (orderByComparator != null) {
1804                            query = new StringBundler(6 +
1805                                            (orderByComparator.getOrderByFields().length * 6));
1806                    }
1807                    else {
1808                            query = new StringBundler(3);
1809                    }
1810    
1811                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1812    
1813                    query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
1814    
1815                    if (orderByComparator != null) {
1816                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1817    
1818                            if (orderByConditionFields.length > 0) {
1819                                    query.append(WHERE_AND);
1820                            }
1821    
1822                            for (int i = 0; i < orderByConditionFields.length; i++) {
1823                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1824                                    query.append(orderByConditionFields[i]);
1825    
1826                                    if ((i + 1) < orderByConditionFields.length) {
1827                                            if (orderByComparator.isAscending() ^ previous) {
1828                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1829                                            }
1830                                            else {
1831                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1832                                            }
1833                                    }
1834                                    else {
1835                                            if (orderByComparator.isAscending() ^ previous) {
1836                                                    query.append(WHERE_GREATER_THAN);
1837                                            }
1838                                            else {
1839                                                    query.append(WHERE_LESSER_THAN);
1840                                            }
1841                                    }
1842                            }
1843    
1844                            query.append(ORDER_BY_CLAUSE);
1845    
1846                            String[] orderByFields = orderByComparator.getOrderByFields();
1847    
1848                            for (int i = 0; i < orderByFields.length; i++) {
1849                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1850                                    query.append(orderByFields[i]);
1851    
1852                                    if ((i + 1) < orderByFields.length) {
1853                                            if (orderByComparator.isAscending() ^ previous) {
1854                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1855                                            }
1856                                            else {
1857                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1858                                            }
1859                                    }
1860                                    else {
1861                                            if (orderByComparator.isAscending() ^ previous) {
1862                                                    query.append(ORDER_BY_ASC);
1863                                            }
1864                                            else {
1865                                                    query.append(ORDER_BY_DESC);
1866                                            }
1867                                    }
1868                            }
1869                    }
1870                    else {
1871                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1872                    }
1873    
1874                    String sql = query.toString();
1875    
1876                    Query q = session.createQuery(sql);
1877    
1878                    q.setFirstResult(0);
1879                    q.setMaxResults(2);
1880    
1881                    QueryPos qPos = QueryPos.getInstance(q);
1882    
1883                    qPos.add(resourcePrimKey);
1884    
1885                    if (orderByComparator != null) {
1886                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
1887    
1888                            for (Object value : values) {
1889                                    qPos.add(value);
1890                            }
1891                    }
1892    
1893                    List<JournalArticle> list = q.list();
1894    
1895                    if (list.size() == 2) {
1896                            return list.get(1);
1897                    }
1898                    else {
1899                            return null;
1900                    }
1901            }
1902    
1903            /**
1904             * Removes all the journal articles where resourcePrimKey = &#63; from the database.
1905             *
1906             * @param resourcePrimKey the resource prim key
1907             * @throws SystemException if a system exception occurred
1908             */
1909            @Override
1910            public void removeByResourcePrimKey(long resourcePrimKey)
1911                    throws SystemException {
1912                    for (JournalArticle journalArticle : findByResourcePrimKey(
1913                                    resourcePrimKey, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1914                            remove(journalArticle);
1915                    }
1916            }
1917    
1918            /**
1919             * Returns the number of journal articles where resourcePrimKey = &#63;.
1920             *
1921             * @param resourcePrimKey the resource prim key
1922             * @return the number of matching journal articles
1923             * @throws SystemException if a system exception occurred
1924             */
1925            @Override
1926            public int countByResourcePrimKey(long resourcePrimKey)
1927                    throws SystemException {
1928                    FinderPath finderPath = FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY;
1929    
1930                    Object[] finderArgs = new Object[] { resourcePrimKey };
1931    
1932                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1933                                    this);
1934    
1935                    if (count == null) {
1936                            StringBundler query = new StringBundler(2);
1937    
1938                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
1939    
1940                            query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
1941    
1942                            String sql = query.toString();
1943    
1944                            Session session = null;
1945    
1946                            try {
1947                                    session = openSession();
1948    
1949                                    Query q = session.createQuery(sql);
1950    
1951                                    QueryPos qPos = QueryPos.getInstance(q);
1952    
1953                                    qPos.add(resourcePrimKey);
1954    
1955                                    count = (Long)q.uniqueResult();
1956    
1957                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1958                            }
1959                            catch (Exception e) {
1960                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1961    
1962                                    throw processException(e);
1963                            }
1964                            finally {
1965                                    closeSession(session);
1966                            }
1967                    }
1968    
1969                    return count.intValue();
1970            }
1971    
1972            private static final String _FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2 =
1973                    "journalArticle.resourcePrimKey = ?";
1974            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1975                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
1976                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1977                            "findByGroupId",
1978                            new String[] {
1979                                    Long.class.getName(),
1980                                    
1981                            Integer.class.getName(), Integer.class.getName(),
1982                                    OrderByComparator.class.getName()
1983                            });
1984            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1985                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1986                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
1987                            JournalArticleImpl.class,
1988                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1989                            new String[] { Long.class.getName() },
1990                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
1991                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
1992                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
1993            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1994                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
1995                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1996                            new String[] { Long.class.getName() });
1997    
1998            /**
1999             * Returns all the journal articles where groupId = &#63;.
2000             *
2001             * @param groupId the group ID
2002             * @return the matching journal articles
2003             * @throws SystemException if a system exception occurred
2004             */
2005            @Override
2006            public List<JournalArticle> findByGroupId(long groupId)
2007                    throws SystemException {
2008                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2009            }
2010    
2011            /**
2012             * Returns a range of all the journal articles where groupId = &#63;.
2013             *
2014             * <p>
2015             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2016             * </p>
2017             *
2018             * @param groupId the group ID
2019             * @param start the lower bound of the range of journal articles
2020             * @param end the upper bound of the range of journal articles (not inclusive)
2021             * @return the range of matching journal articles
2022             * @throws SystemException if a system exception occurred
2023             */
2024            @Override
2025            public List<JournalArticle> findByGroupId(long groupId, int start, int end)
2026                    throws SystemException {
2027                    return findByGroupId(groupId, start, end, null);
2028            }
2029    
2030            /**
2031             * Returns an ordered range of all the journal articles where groupId = &#63;.
2032             *
2033             * <p>
2034             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2035             * </p>
2036             *
2037             * @param groupId the group ID
2038             * @param start the lower bound of the range of journal articles
2039             * @param end the upper bound of the range of journal articles (not inclusive)
2040             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2041             * @return the ordered range of matching journal articles
2042             * @throws SystemException if a system exception occurred
2043             */
2044            @Override
2045            public List<JournalArticle> findByGroupId(long groupId, int start, int end,
2046                    OrderByComparator orderByComparator) throws SystemException {
2047                    boolean pagination = true;
2048                    FinderPath finderPath = null;
2049                    Object[] finderArgs = null;
2050    
2051                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2052                                    (orderByComparator == null)) {
2053                            pagination = false;
2054                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
2055                            finderArgs = new Object[] { groupId };
2056                    }
2057                    else {
2058                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
2059                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
2060                    }
2061    
2062                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
2063                                    finderArgs, this);
2064    
2065                    if ((list != null) && !list.isEmpty()) {
2066                            for (JournalArticle journalArticle : list) {
2067                                    if ((groupId != journalArticle.getGroupId())) {
2068                                            list = null;
2069    
2070                                            break;
2071                                    }
2072                            }
2073                    }
2074    
2075                    if (list == null) {
2076                            StringBundler query = null;
2077    
2078                            if (orderByComparator != null) {
2079                                    query = new StringBundler(3 +
2080                                                    (orderByComparator.getOrderByFields().length * 3));
2081                            }
2082                            else {
2083                                    query = new StringBundler(3);
2084                            }
2085    
2086                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2087    
2088                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2089    
2090                            if (orderByComparator != null) {
2091                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2092                                            orderByComparator);
2093                            }
2094                            else
2095                             if (pagination) {
2096                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2097                            }
2098    
2099                            String sql = query.toString();
2100    
2101                            Session session = null;
2102    
2103                            try {
2104                                    session = openSession();
2105    
2106                                    Query q = session.createQuery(sql);
2107    
2108                                    QueryPos qPos = QueryPos.getInstance(q);
2109    
2110                                    qPos.add(groupId);
2111    
2112                                    if (!pagination) {
2113                                            list = (List<JournalArticle>)QueryUtil.list(q,
2114                                                            getDialect(), start, end, false);
2115    
2116                                            Collections.sort(list);
2117    
2118                                            list = new UnmodifiableList<JournalArticle>(list);
2119                                    }
2120                                    else {
2121                                            list = (List<JournalArticle>)QueryUtil.list(q,
2122                                                            getDialect(), start, end);
2123                                    }
2124    
2125                                    cacheResult(list);
2126    
2127                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2128                            }
2129                            catch (Exception e) {
2130                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2131    
2132                                    throw processException(e);
2133                            }
2134                            finally {
2135                                    closeSession(session);
2136                            }
2137                    }
2138    
2139                    return list;
2140            }
2141    
2142            /**
2143             * Returns the first journal article in the ordered set where groupId = &#63;.
2144             *
2145             * @param groupId the group ID
2146             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2147             * @return the first matching journal article
2148             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2149             * @throws SystemException if a system exception occurred
2150             */
2151            @Override
2152            public JournalArticle findByGroupId_First(long groupId,
2153                    OrderByComparator orderByComparator)
2154                    throws NoSuchArticleException, SystemException {
2155                    JournalArticle journalArticle = fetchByGroupId_First(groupId,
2156                                    orderByComparator);
2157    
2158                    if (journalArticle != null) {
2159                            return journalArticle;
2160                    }
2161    
2162                    StringBundler msg = new StringBundler(4);
2163    
2164                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2165    
2166                    msg.append("groupId=");
2167                    msg.append(groupId);
2168    
2169                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2170    
2171                    throw new NoSuchArticleException(msg.toString());
2172            }
2173    
2174            /**
2175             * Returns the first journal article in the ordered set where groupId = &#63;.
2176             *
2177             * @param groupId the group ID
2178             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2179             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
2180             * @throws SystemException if a system exception occurred
2181             */
2182            @Override
2183            public JournalArticle fetchByGroupId_First(long groupId,
2184                    OrderByComparator orderByComparator) throws SystemException {
2185                    List<JournalArticle> list = findByGroupId(groupId, 0, 1,
2186                                    orderByComparator);
2187    
2188                    if (!list.isEmpty()) {
2189                            return list.get(0);
2190                    }
2191    
2192                    return null;
2193            }
2194    
2195            /**
2196             * Returns the last journal article in the ordered set where groupId = &#63;.
2197             *
2198             * @param groupId the group ID
2199             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2200             * @return the last matching journal article
2201             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2202             * @throws SystemException if a system exception occurred
2203             */
2204            @Override
2205            public JournalArticle findByGroupId_Last(long groupId,
2206                    OrderByComparator orderByComparator)
2207                    throws NoSuchArticleException, SystemException {
2208                    JournalArticle journalArticle = fetchByGroupId_Last(groupId,
2209                                    orderByComparator);
2210    
2211                    if (journalArticle != null) {
2212                            return journalArticle;
2213                    }
2214    
2215                    StringBundler msg = new StringBundler(4);
2216    
2217                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2218    
2219                    msg.append("groupId=");
2220                    msg.append(groupId);
2221    
2222                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2223    
2224                    throw new NoSuchArticleException(msg.toString());
2225            }
2226    
2227            /**
2228             * Returns the last journal article in the ordered set where groupId = &#63;.
2229             *
2230             * @param groupId the group ID
2231             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2232             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
2233             * @throws SystemException if a system exception occurred
2234             */
2235            @Override
2236            public JournalArticle fetchByGroupId_Last(long groupId,
2237                    OrderByComparator orderByComparator) throws SystemException {
2238                    int count = countByGroupId(groupId);
2239    
2240                    if (count == 0) {
2241                            return null;
2242                    }
2243    
2244                    List<JournalArticle> list = findByGroupId(groupId, count - 1, count,
2245                                    orderByComparator);
2246    
2247                    if (!list.isEmpty()) {
2248                            return list.get(0);
2249                    }
2250    
2251                    return null;
2252            }
2253    
2254            /**
2255             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63;.
2256             *
2257             * @param id the primary key of the current journal article
2258             * @param groupId the group ID
2259             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2260             * @return the previous, current, and next journal article
2261             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
2262             * @throws SystemException if a system exception occurred
2263             */
2264            @Override
2265            public JournalArticle[] findByGroupId_PrevAndNext(long id, long groupId,
2266                    OrderByComparator orderByComparator)
2267                    throws NoSuchArticleException, SystemException {
2268                    JournalArticle journalArticle = findByPrimaryKey(id);
2269    
2270                    Session session = null;
2271    
2272                    try {
2273                            session = openSession();
2274    
2275                            JournalArticle[] array = new JournalArticleImpl[3];
2276    
2277                            array[0] = getByGroupId_PrevAndNext(session, journalArticle,
2278                                            groupId, orderByComparator, true);
2279    
2280                            array[1] = journalArticle;
2281    
2282                            array[2] = getByGroupId_PrevAndNext(session, journalArticle,
2283                                            groupId, orderByComparator, false);
2284    
2285                            return array;
2286                    }
2287                    catch (Exception e) {
2288                            throw processException(e);
2289                    }
2290                    finally {
2291                            closeSession(session);
2292                    }
2293            }
2294    
2295            protected JournalArticle getByGroupId_PrevAndNext(Session session,
2296                    JournalArticle journalArticle, long groupId,
2297                    OrderByComparator orderByComparator, boolean previous) {
2298                    StringBundler query = null;
2299    
2300                    if (orderByComparator != null) {
2301                            query = new StringBundler(6 +
2302                                            (orderByComparator.getOrderByFields().length * 6));
2303                    }
2304                    else {
2305                            query = new StringBundler(3);
2306                    }
2307    
2308                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2309    
2310                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2311    
2312                    if (orderByComparator != null) {
2313                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2314    
2315                            if (orderByConditionFields.length > 0) {
2316                                    query.append(WHERE_AND);
2317                            }
2318    
2319                            for (int i = 0; i < orderByConditionFields.length; i++) {
2320                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2321                                    query.append(orderByConditionFields[i]);
2322    
2323                                    if ((i + 1) < orderByConditionFields.length) {
2324                                            if (orderByComparator.isAscending() ^ previous) {
2325                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2326                                            }
2327                                            else {
2328                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2329                                            }
2330                                    }
2331                                    else {
2332                                            if (orderByComparator.isAscending() ^ previous) {
2333                                                    query.append(WHERE_GREATER_THAN);
2334                                            }
2335                                            else {
2336                                                    query.append(WHERE_LESSER_THAN);
2337                                            }
2338                                    }
2339                            }
2340    
2341                            query.append(ORDER_BY_CLAUSE);
2342    
2343                            String[] orderByFields = orderByComparator.getOrderByFields();
2344    
2345                            for (int i = 0; i < orderByFields.length; i++) {
2346                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2347                                    query.append(orderByFields[i]);
2348    
2349                                    if ((i + 1) < orderByFields.length) {
2350                                            if (orderByComparator.isAscending() ^ previous) {
2351                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2352                                            }
2353                                            else {
2354                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2355                                            }
2356                                    }
2357                                    else {
2358                                            if (orderByComparator.isAscending() ^ previous) {
2359                                                    query.append(ORDER_BY_ASC);
2360                                            }
2361                                            else {
2362                                                    query.append(ORDER_BY_DESC);
2363                                            }
2364                                    }
2365                            }
2366                    }
2367                    else {
2368                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2369                    }
2370    
2371                    String sql = query.toString();
2372    
2373                    Query q = session.createQuery(sql);
2374    
2375                    q.setFirstResult(0);
2376                    q.setMaxResults(2);
2377    
2378                    QueryPos qPos = QueryPos.getInstance(q);
2379    
2380                    qPos.add(groupId);
2381    
2382                    if (orderByComparator != null) {
2383                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
2384    
2385                            for (Object value : values) {
2386                                    qPos.add(value);
2387                            }
2388                    }
2389    
2390                    List<JournalArticle> list = q.list();
2391    
2392                    if (list.size() == 2) {
2393                            return list.get(1);
2394                    }
2395                    else {
2396                            return null;
2397                    }
2398            }
2399    
2400            /**
2401             * Returns all the journal articles that the user has permission to view where groupId = &#63;.
2402             *
2403             * @param groupId the group ID
2404             * @return the matching journal articles that the user has permission to view
2405             * @throws SystemException if a system exception occurred
2406             */
2407            @Override
2408            public List<JournalArticle> filterFindByGroupId(long groupId)
2409                    throws SystemException {
2410                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
2411                            QueryUtil.ALL_POS, null);
2412            }
2413    
2414            /**
2415             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63;.
2416             *
2417             * <p>
2418             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2419             * </p>
2420             *
2421             * @param groupId the group ID
2422             * @param start the lower bound of the range of journal articles
2423             * @param end the upper bound of the range of journal articles (not inclusive)
2424             * @return the range of matching journal articles that the user has permission to view
2425             * @throws SystemException if a system exception occurred
2426             */
2427            @Override
2428            public List<JournalArticle> filterFindByGroupId(long groupId, int start,
2429                    int end) throws SystemException {
2430                    return filterFindByGroupId(groupId, start, end, null);
2431            }
2432    
2433            /**
2434             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63;.
2435             *
2436             * <p>
2437             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2438             * </p>
2439             *
2440             * @param groupId the group ID
2441             * @param start the lower bound of the range of journal articles
2442             * @param end the upper bound of the range of journal articles (not inclusive)
2443             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2444             * @return the ordered range of matching journal articles that the user has permission to view
2445             * @throws SystemException if a system exception occurred
2446             */
2447            @Override
2448            public List<JournalArticle> filterFindByGroupId(long groupId, int start,
2449                    int end, OrderByComparator orderByComparator) throws SystemException {
2450                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2451                            return findByGroupId(groupId, start, end, orderByComparator);
2452                    }
2453    
2454                    StringBundler query = null;
2455    
2456                    if (orderByComparator != null) {
2457                            query = new StringBundler(3 +
2458                                            (orderByComparator.getOrderByFields().length * 3));
2459                    }
2460                    else {
2461                            query = new StringBundler(3);
2462                    }
2463    
2464                    if (getDB().isSupportsInlineDistinct()) {
2465                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
2466                    }
2467                    else {
2468                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
2469                    }
2470    
2471                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2472    
2473                    if (!getDB().isSupportsInlineDistinct()) {
2474                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
2475                    }
2476    
2477                    if (orderByComparator != null) {
2478                            if (getDB().isSupportsInlineDistinct()) {
2479                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2480                                            orderByComparator, true);
2481                            }
2482                            else {
2483                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2484                                            orderByComparator, true);
2485                            }
2486                    }
2487                    else {
2488                            if (getDB().isSupportsInlineDistinct()) {
2489                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2490                            }
2491                            else {
2492                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
2493                            }
2494                    }
2495    
2496                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2497                                    JournalArticle.class.getName(),
2498                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2499    
2500                    Session session = null;
2501    
2502                    try {
2503                            session = openSession();
2504    
2505                            SQLQuery q = session.createSQLQuery(sql);
2506    
2507                            if (getDB().isSupportsInlineDistinct()) {
2508                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
2509                            }
2510                            else {
2511                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
2512                            }
2513    
2514                            QueryPos qPos = QueryPos.getInstance(q);
2515    
2516                            qPos.add(groupId);
2517    
2518                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
2519                                    end);
2520                    }
2521                    catch (Exception e) {
2522                            throw processException(e);
2523                    }
2524                    finally {
2525                            closeSession(session);
2526                    }
2527            }
2528    
2529            /**
2530             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63;.
2531             *
2532             * @param id the primary key of the current journal article
2533             * @param groupId the group ID
2534             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2535             * @return the previous, current, and next journal article
2536             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
2537             * @throws SystemException if a system exception occurred
2538             */
2539            @Override
2540            public JournalArticle[] filterFindByGroupId_PrevAndNext(long id,
2541                    long groupId, OrderByComparator orderByComparator)
2542                    throws NoSuchArticleException, SystemException {
2543                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2544                            return findByGroupId_PrevAndNext(id, groupId, orderByComparator);
2545                    }
2546    
2547                    JournalArticle journalArticle = findByPrimaryKey(id);
2548    
2549                    Session session = null;
2550    
2551                    try {
2552                            session = openSession();
2553    
2554                            JournalArticle[] array = new JournalArticleImpl[3];
2555    
2556                            array[0] = filterGetByGroupId_PrevAndNext(session, journalArticle,
2557                                            groupId, orderByComparator, true);
2558    
2559                            array[1] = journalArticle;
2560    
2561                            array[2] = filterGetByGroupId_PrevAndNext(session, journalArticle,
2562                                            groupId, orderByComparator, false);
2563    
2564                            return array;
2565                    }
2566                    catch (Exception e) {
2567                            throw processException(e);
2568                    }
2569                    finally {
2570                            closeSession(session);
2571                    }
2572            }
2573    
2574            protected JournalArticle filterGetByGroupId_PrevAndNext(Session session,
2575                    JournalArticle journalArticle, long groupId,
2576                    OrderByComparator orderByComparator, boolean previous) {
2577                    StringBundler query = null;
2578    
2579                    if (orderByComparator != null) {
2580                            query = new StringBundler(6 +
2581                                            (orderByComparator.getOrderByFields().length * 6));
2582                    }
2583                    else {
2584                            query = new StringBundler(3);
2585                    }
2586    
2587                    if (getDB().isSupportsInlineDistinct()) {
2588                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
2589                    }
2590                    else {
2591                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
2592                    }
2593    
2594                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2595    
2596                    if (!getDB().isSupportsInlineDistinct()) {
2597                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
2598                    }
2599    
2600                    if (orderByComparator != null) {
2601                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2602    
2603                            if (orderByConditionFields.length > 0) {
2604                                    query.append(WHERE_AND);
2605                            }
2606    
2607                            for (int i = 0; i < orderByConditionFields.length; i++) {
2608                                    if (getDB().isSupportsInlineDistinct()) {
2609                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2610                                    }
2611                                    else {
2612                                            query.append(_ORDER_BY_ENTITY_TABLE);
2613                                    }
2614    
2615                                    query.append(orderByConditionFields[i]);
2616    
2617                                    if ((i + 1) < orderByConditionFields.length) {
2618                                            if (orderByComparator.isAscending() ^ previous) {
2619                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2620                                            }
2621                                            else {
2622                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2623                                            }
2624                                    }
2625                                    else {
2626                                            if (orderByComparator.isAscending() ^ previous) {
2627                                                    query.append(WHERE_GREATER_THAN);
2628                                            }
2629                                            else {
2630                                                    query.append(WHERE_LESSER_THAN);
2631                                            }
2632                                    }
2633                            }
2634    
2635                            query.append(ORDER_BY_CLAUSE);
2636    
2637                            String[] orderByFields = orderByComparator.getOrderByFields();
2638    
2639                            for (int i = 0; i < orderByFields.length; i++) {
2640                                    if (getDB().isSupportsInlineDistinct()) {
2641                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2642                                    }
2643                                    else {
2644                                            query.append(_ORDER_BY_ENTITY_TABLE);
2645                                    }
2646    
2647                                    query.append(orderByFields[i]);
2648    
2649                                    if ((i + 1) < orderByFields.length) {
2650                                            if (orderByComparator.isAscending() ^ previous) {
2651                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2652                                            }
2653                                            else {
2654                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2655                                            }
2656                                    }
2657                                    else {
2658                                            if (orderByComparator.isAscending() ^ previous) {
2659                                                    query.append(ORDER_BY_ASC);
2660                                            }
2661                                            else {
2662                                                    query.append(ORDER_BY_DESC);
2663                                            }
2664                                    }
2665                            }
2666                    }
2667                    else {
2668                            if (getDB().isSupportsInlineDistinct()) {
2669                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2670                            }
2671                            else {
2672                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
2673                            }
2674                    }
2675    
2676                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2677                                    JournalArticle.class.getName(),
2678                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2679    
2680                    SQLQuery q = session.createSQLQuery(sql);
2681    
2682                    q.setFirstResult(0);
2683                    q.setMaxResults(2);
2684    
2685                    if (getDB().isSupportsInlineDistinct()) {
2686                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
2687                    }
2688                    else {
2689                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
2690                    }
2691    
2692                    QueryPos qPos = QueryPos.getInstance(q);
2693    
2694                    qPos.add(groupId);
2695    
2696                    if (orderByComparator != null) {
2697                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
2698    
2699                            for (Object value : values) {
2700                                    qPos.add(value);
2701                            }
2702                    }
2703    
2704                    List<JournalArticle> list = q.list();
2705    
2706                    if (list.size() == 2) {
2707                            return list.get(1);
2708                    }
2709                    else {
2710                            return null;
2711                    }
2712            }
2713    
2714            /**
2715             * Removes all the journal articles where groupId = &#63; from the database.
2716             *
2717             * @param groupId the group ID
2718             * @throws SystemException if a system exception occurred
2719             */
2720            @Override
2721            public void removeByGroupId(long groupId) throws SystemException {
2722                    for (JournalArticle journalArticle : findByGroupId(groupId,
2723                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2724                            remove(journalArticle);
2725                    }
2726            }
2727    
2728            /**
2729             * Returns the number of journal articles where groupId = &#63;.
2730             *
2731             * @param groupId the group ID
2732             * @return the number of matching journal articles
2733             * @throws SystemException if a system exception occurred
2734             */
2735            @Override
2736            public int countByGroupId(long groupId) throws SystemException {
2737                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2738    
2739                    Object[] finderArgs = new Object[] { groupId };
2740    
2741                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2742                                    this);
2743    
2744                    if (count == null) {
2745                            StringBundler query = new StringBundler(2);
2746    
2747                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
2748    
2749                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2750    
2751                            String sql = query.toString();
2752    
2753                            Session session = null;
2754    
2755                            try {
2756                                    session = openSession();
2757    
2758                                    Query q = session.createQuery(sql);
2759    
2760                                    QueryPos qPos = QueryPos.getInstance(q);
2761    
2762                                    qPos.add(groupId);
2763    
2764                                    count = (Long)q.uniqueResult();
2765    
2766                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2767                            }
2768                            catch (Exception e) {
2769                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2770    
2771                                    throw processException(e);
2772                            }
2773                            finally {
2774                                    closeSession(session);
2775                            }
2776                    }
2777    
2778                    return count.intValue();
2779            }
2780    
2781            /**
2782             * Returns the number of journal articles that the user has permission to view where groupId = &#63;.
2783             *
2784             * @param groupId the group ID
2785             * @return the number of matching journal articles that the user has permission to view
2786             * @throws SystemException if a system exception occurred
2787             */
2788            @Override
2789            public int filterCountByGroupId(long groupId) throws SystemException {
2790                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2791                            return countByGroupId(groupId);
2792                    }
2793    
2794                    StringBundler query = new StringBundler(2);
2795    
2796                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
2797    
2798                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2799    
2800                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2801                                    JournalArticle.class.getName(),
2802                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2803    
2804                    Session session = null;
2805    
2806                    try {
2807                            session = openSession();
2808    
2809                            SQLQuery q = session.createSQLQuery(sql);
2810    
2811                            q.addScalar(COUNT_COLUMN_NAME,
2812                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2813    
2814                            QueryPos qPos = QueryPos.getInstance(q);
2815    
2816                            qPos.add(groupId);
2817    
2818                            Long count = (Long)q.uniqueResult();
2819    
2820                            return count.intValue();
2821                    }
2822                    catch (Exception e) {
2823                            throw processException(e);
2824                    }
2825                    finally {
2826                            closeSession(session);
2827                    }
2828            }
2829    
2830            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "journalArticle.groupId = ?";
2831            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2832                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
2833                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
2834                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2835                            "findByCompanyId",
2836                            new String[] {
2837                                    Long.class.getName(),
2838                                    
2839                            Integer.class.getName(), Integer.class.getName(),
2840                                    OrderByComparator.class.getName()
2841                            });
2842            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2843                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
2844                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
2845                            JournalArticleImpl.class,
2846                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2847                            new String[] { Long.class.getName() },
2848                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
2849                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
2850                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
2851            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
2852                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
2853                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2854                            new String[] { Long.class.getName() });
2855    
2856            /**
2857             * Returns all the journal articles where companyId = &#63;.
2858             *
2859             * @param companyId the company ID
2860             * @return the matching journal articles
2861             * @throws SystemException if a system exception occurred
2862             */
2863            @Override
2864            public List<JournalArticle> findByCompanyId(long companyId)
2865                    throws SystemException {
2866                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2867                            null);
2868            }
2869    
2870            /**
2871             * Returns a range of all the journal articles where companyId = &#63;.
2872             *
2873             * <p>
2874             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2875             * </p>
2876             *
2877             * @param companyId the company ID
2878             * @param start the lower bound of the range of journal articles
2879             * @param end the upper bound of the range of journal articles (not inclusive)
2880             * @return the range of matching journal articles
2881             * @throws SystemException if a system exception occurred
2882             */
2883            @Override
2884            public List<JournalArticle> findByCompanyId(long companyId, int start,
2885                    int end) throws SystemException {
2886                    return findByCompanyId(companyId, start, end, null);
2887            }
2888    
2889            /**
2890             * Returns an ordered range of all the journal articles where companyId = &#63;.
2891             *
2892             * <p>
2893             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2894             * </p>
2895             *
2896             * @param companyId the company ID
2897             * @param start the lower bound of the range of journal articles
2898             * @param end the upper bound of the range of journal articles (not inclusive)
2899             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2900             * @return the ordered range of matching journal articles
2901             * @throws SystemException if a system exception occurred
2902             */
2903            @Override
2904            public List<JournalArticle> findByCompanyId(long companyId, int start,
2905                    int end, OrderByComparator orderByComparator) throws SystemException {
2906                    boolean pagination = true;
2907                    FinderPath finderPath = null;
2908                    Object[] finderArgs = null;
2909    
2910                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2911                                    (orderByComparator == null)) {
2912                            pagination = false;
2913                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2914                            finderArgs = new Object[] { companyId };
2915                    }
2916                    else {
2917                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2918                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2919                    }
2920    
2921                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
2922                                    finderArgs, this);
2923    
2924                    if ((list != null) && !list.isEmpty()) {
2925                            for (JournalArticle journalArticle : list) {
2926                                    if ((companyId != journalArticle.getCompanyId())) {
2927                                            list = null;
2928    
2929                                            break;
2930                                    }
2931                            }
2932                    }
2933    
2934                    if (list == null) {
2935                            StringBundler query = null;
2936    
2937                            if (orderByComparator != null) {
2938                                    query = new StringBundler(3 +
2939                                                    (orderByComparator.getOrderByFields().length * 3));
2940                            }
2941                            else {
2942                                    query = new StringBundler(3);
2943                            }
2944    
2945                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2946    
2947                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2948    
2949                            if (orderByComparator != null) {
2950                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2951                                            orderByComparator);
2952                            }
2953                            else
2954                             if (pagination) {
2955                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2956                            }
2957    
2958                            String sql = query.toString();
2959    
2960                            Session session = null;
2961    
2962                            try {
2963                                    session = openSession();
2964    
2965                                    Query q = session.createQuery(sql);
2966    
2967                                    QueryPos qPos = QueryPos.getInstance(q);
2968    
2969                                    qPos.add(companyId);
2970    
2971                                    if (!pagination) {
2972                                            list = (List<JournalArticle>)QueryUtil.list(q,
2973                                                            getDialect(), start, end, false);
2974    
2975                                            Collections.sort(list);
2976    
2977                                            list = new UnmodifiableList<JournalArticle>(list);
2978                                    }
2979                                    else {
2980                                            list = (List<JournalArticle>)QueryUtil.list(q,
2981                                                            getDialect(), start, end);
2982                                    }
2983    
2984                                    cacheResult(list);
2985    
2986                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2987                            }
2988                            catch (Exception e) {
2989                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2990    
2991                                    throw processException(e);
2992                            }
2993                            finally {
2994                                    closeSession(session);
2995                            }
2996                    }
2997    
2998                    return list;
2999            }
3000    
3001            /**
3002             * Returns the first journal article in the ordered set where companyId = &#63;.
3003             *
3004             * @param companyId the company ID
3005             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3006             * @return the first matching journal article
3007             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3008             * @throws SystemException if a system exception occurred
3009             */
3010            @Override
3011            public JournalArticle findByCompanyId_First(long companyId,
3012                    OrderByComparator orderByComparator)
3013                    throws NoSuchArticleException, SystemException {
3014                    JournalArticle journalArticle = fetchByCompanyId_First(companyId,
3015                                    orderByComparator);
3016    
3017                    if (journalArticle != null) {
3018                            return journalArticle;
3019                    }
3020    
3021                    StringBundler msg = new StringBundler(4);
3022    
3023                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3024    
3025                    msg.append("companyId=");
3026                    msg.append(companyId);
3027    
3028                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3029    
3030                    throw new NoSuchArticleException(msg.toString());
3031            }
3032    
3033            /**
3034             * Returns the first journal article in the ordered set where companyId = &#63;.
3035             *
3036             * @param companyId the company ID
3037             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3038             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
3039             * @throws SystemException if a system exception occurred
3040             */
3041            @Override
3042            public JournalArticle fetchByCompanyId_First(long companyId,
3043                    OrderByComparator orderByComparator) throws SystemException {
3044                    List<JournalArticle> list = findByCompanyId(companyId, 0, 1,
3045                                    orderByComparator);
3046    
3047                    if (!list.isEmpty()) {
3048                            return list.get(0);
3049                    }
3050    
3051                    return null;
3052            }
3053    
3054            /**
3055             * Returns the last journal article in the ordered set where companyId = &#63;.
3056             *
3057             * @param companyId the company ID
3058             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3059             * @return the last matching journal article
3060             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3061             * @throws SystemException if a system exception occurred
3062             */
3063            @Override
3064            public JournalArticle findByCompanyId_Last(long companyId,
3065                    OrderByComparator orderByComparator)
3066                    throws NoSuchArticleException, SystemException {
3067                    JournalArticle journalArticle = fetchByCompanyId_Last(companyId,
3068                                    orderByComparator);
3069    
3070                    if (journalArticle != null) {
3071                            return journalArticle;
3072                    }
3073    
3074                    StringBundler msg = new StringBundler(4);
3075    
3076                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3077    
3078                    msg.append("companyId=");
3079                    msg.append(companyId);
3080    
3081                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3082    
3083                    throw new NoSuchArticleException(msg.toString());
3084            }
3085    
3086            /**
3087             * Returns the last journal article in the ordered set where companyId = &#63;.
3088             *
3089             * @param companyId the company ID
3090             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3091             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
3092             * @throws SystemException if a system exception occurred
3093             */
3094            @Override
3095            public JournalArticle fetchByCompanyId_Last(long companyId,
3096                    OrderByComparator orderByComparator) throws SystemException {
3097                    int count = countByCompanyId(companyId);
3098    
3099                    if (count == 0) {
3100                            return null;
3101                    }
3102    
3103                    List<JournalArticle> list = findByCompanyId(companyId, count - 1,
3104                                    count, orderByComparator);
3105    
3106                    if (!list.isEmpty()) {
3107                            return list.get(0);
3108                    }
3109    
3110                    return null;
3111            }
3112    
3113            /**
3114             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63;.
3115             *
3116             * @param id the primary key of the current journal article
3117             * @param companyId the company ID
3118             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3119             * @return the previous, current, and next journal article
3120             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
3121             * @throws SystemException if a system exception occurred
3122             */
3123            @Override
3124            public JournalArticle[] findByCompanyId_PrevAndNext(long id,
3125                    long companyId, OrderByComparator orderByComparator)
3126                    throws NoSuchArticleException, SystemException {
3127                    JournalArticle journalArticle = findByPrimaryKey(id);
3128    
3129                    Session session = null;
3130    
3131                    try {
3132                            session = openSession();
3133    
3134                            JournalArticle[] array = new JournalArticleImpl[3];
3135    
3136                            array[0] = getByCompanyId_PrevAndNext(session, journalArticle,
3137                                            companyId, orderByComparator, true);
3138    
3139                            array[1] = journalArticle;
3140    
3141                            array[2] = getByCompanyId_PrevAndNext(session, journalArticle,
3142                                            companyId, orderByComparator, false);
3143    
3144                            return array;
3145                    }
3146                    catch (Exception e) {
3147                            throw processException(e);
3148                    }
3149                    finally {
3150                            closeSession(session);
3151                    }
3152            }
3153    
3154            protected JournalArticle getByCompanyId_PrevAndNext(Session session,
3155                    JournalArticle journalArticle, long companyId,
3156                    OrderByComparator orderByComparator, boolean previous) {
3157                    StringBundler query = null;
3158    
3159                    if (orderByComparator != null) {
3160                            query = new StringBundler(6 +
3161                                            (orderByComparator.getOrderByFields().length * 6));
3162                    }
3163                    else {
3164                            query = new StringBundler(3);
3165                    }
3166    
3167                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3168    
3169                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3170    
3171                    if (orderByComparator != null) {
3172                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3173    
3174                            if (orderByConditionFields.length > 0) {
3175                                    query.append(WHERE_AND);
3176                            }
3177    
3178                            for (int i = 0; i < orderByConditionFields.length; i++) {
3179                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3180                                    query.append(orderByConditionFields[i]);
3181    
3182                                    if ((i + 1) < orderByConditionFields.length) {
3183                                            if (orderByComparator.isAscending() ^ previous) {
3184                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3185                                            }
3186                                            else {
3187                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3188                                            }
3189                                    }
3190                                    else {
3191                                            if (orderByComparator.isAscending() ^ previous) {
3192                                                    query.append(WHERE_GREATER_THAN);
3193                                            }
3194                                            else {
3195                                                    query.append(WHERE_LESSER_THAN);
3196                                            }
3197                                    }
3198                            }
3199    
3200                            query.append(ORDER_BY_CLAUSE);
3201    
3202                            String[] orderByFields = orderByComparator.getOrderByFields();
3203    
3204                            for (int i = 0; i < orderByFields.length; i++) {
3205                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3206                                    query.append(orderByFields[i]);
3207    
3208                                    if ((i + 1) < orderByFields.length) {
3209                                            if (orderByComparator.isAscending() ^ previous) {
3210                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3211                                            }
3212                                            else {
3213                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3214                                            }
3215                                    }
3216                                    else {
3217                                            if (orderByComparator.isAscending() ^ previous) {
3218                                                    query.append(ORDER_BY_ASC);
3219                                            }
3220                                            else {
3221                                                    query.append(ORDER_BY_DESC);
3222                                            }
3223                                    }
3224                            }
3225                    }
3226                    else {
3227                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3228                    }
3229    
3230                    String sql = query.toString();
3231    
3232                    Query q = session.createQuery(sql);
3233    
3234                    q.setFirstResult(0);
3235                    q.setMaxResults(2);
3236    
3237                    QueryPos qPos = QueryPos.getInstance(q);
3238    
3239                    qPos.add(companyId);
3240    
3241                    if (orderByComparator != null) {
3242                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
3243    
3244                            for (Object value : values) {
3245                                    qPos.add(value);
3246                            }
3247                    }
3248    
3249                    List<JournalArticle> list = q.list();
3250    
3251                    if (list.size() == 2) {
3252                            return list.get(1);
3253                    }
3254                    else {
3255                            return null;
3256                    }
3257            }
3258    
3259            /**
3260             * Removes all the journal articles where companyId = &#63; from the database.
3261             *
3262             * @param companyId the company ID
3263             * @throws SystemException if a system exception occurred
3264             */
3265            @Override
3266            public void removeByCompanyId(long companyId) throws SystemException {
3267                    for (JournalArticle journalArticle : findByCompanyId(companyId,
3268                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3269                            remove(journalArticle);
3270                    }
3271            }
3272    
3273            /**
3274             * Returns the number of journal articles where companyId = &#63;.
3275             *
3276             * @param companyId the company ID
3277             * @return the number of matching journal articles
3278             * @throws SystemException if a system exception occurred
3279             */
3280            @Override
3281            public int countByCompanyId(long companyId) throws SystemException {
3282                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
3283    
3284                    Object[] finderArgs = new Object[] { companyId };
3285    
3286                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3287                                    this);
3288    
3289                    if (count == null) {
3290                            StringBundler query = new StringBundler(2);
3291    
3292                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
3293    
3294                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3295    
3296                            String sql = query.toString();
3297    
3298                            Session session = null;
3299    
3300                            try {
3301                                    session = openSession();
3302    
3303                                    Query q = session.createQuery(sql);
3304    
3305                                    QueryPos qPos = QueryPos.getInstance(q);
3306    
3307                                    qPos.add(companyId);
3308    
3309                                    count = (Long)q.uniqueResult();
3310    
3311                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3312                            }
3313                            catch (Exception e) {
3314                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3315    
3316                                    throw processException(e);
3317                            }
3318                            finally {
3319                                    closeSession(session);
3320                            }
3321                    }
3322    
3323                    return count.intValue();
3324            }
3325    
3326            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "journalArticle.companyId = ?";
3327            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID =
3328                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3329                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
3330                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
3331                            "findByStructureId",
3332                            new String[] {
3333                                    String.class.getName(),
3334                                    
3335                            Integer.class.getName(), Integer.class.getName(),
3336                                    OrderByComparator.class.getName()
3337                            });
3338            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID =
3339                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3340                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
3341                            JournalArticleImpl.class,
3342                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByStructureId",
3343                            new String[] { String.class.getName() },
3344                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK |
3345                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
3346                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
3347            public static final FinderPath FINDER_PATH_COUNT_BY_STRUCTUREID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3348                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
3349                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByStructureId",
3350                            new String[] { String.class.getName() });
3351            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_STRUCTUREID =
3352                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3353                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
3354                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByStructureId",
3355                            new String[] { String.class.getName() });
3356    
3357            /**
3358             * Returns all the journal articles where structureId = &#63;.
3359             *
3360             * @param structureId the structure ID
3361             * @return the matching journal articles
3362             * @throws SystemException if a system exception occurred
3363             */
3364            @Override
3365            public List<JournalArticle> findByStructureId(String structureId)
3366                    throws SystemException {
3367                    return findByStructureId(structureId, QueryUtil.ALL_POS,
3368                            QueryUtil.ALL_POS, null);
3369            }
3370    
3371            /**
3372             * Returns a range of all the journal articles where structureId = &#63;.
3373             *
3374             * <p>
3375             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3376             * </p>
3377             *
3378             * @param structureId the structure ID
3379             * @param start the lower bound of the range of journal articles
3380             * @param end the upper bound of the range of journal articles (not inclusive)
3381             * @return the range of matching journal articles
3382             * @throws SystemException if a system exception occurred
3383             */
3384            @Override
3385            public List<JournalArticle> findByStructureId(String structureId,
3386                    int start, int end) throws SystemException {
3387                    return findByStructureId(structureId, start, end, null);
3388            }
3389    
3390            /**
3391             * Returns an ordered range of all the journal articles where structureId = &#63;.
3392             *
3393             * <p>
3394             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3395             * </p>
3396             *
3397             * @param structureId the structure ID
3398             * @param start the lower bound of the range of journal articles
3399             * @param end the upper bound of the range of journal articles (not inclusive)
3400             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3401             * @return the ordered range of matching journal articles
3402             * @throws SystemException if a system exception occurred
3403             */
3404            @Override
3405            public List<JournalArticle> findByStructureId(String structureId,
3406                    int start, int end, OrderByComparator orderByComparator)
3407                    throws SystemException {
3408                    boolean pagination = true;
3409                    FinderPath finderPath = null;
3410                    Object[] finderArgs = null;
3411    
3412                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3413                                    (orderByComparator == null)) {
3414                            pagination = false;
3415                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID;
3416                            finderArgs = new Object[] { structureId };
3417                    }
3418                    else {
3419                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID;
3420                            finderArgs = new Object[] { structureId, start, end, orderByComparator };
3421                    }
3422    
3423                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
3424                                    finderArgs, this);
3425    
3426                    if ((list != null) && !list.isEmpty()) {
3427                            for (JournalArticle journalArticle : list) {
3428                                    if (!Validator.equals(structureId,
3429                                                            journalArticle.getStructureId())) {
3430                                            list = null;
3431    
3432                                            break;
3433                                    }
3434                            }
3435                    }
3436    
3437                    if (list == null) {
3438                            StringBundler query = null;
3439    
3440                            if (orderByComparator != null) {
3441                                    query = new StringBundler(3 +
3442                                                    (orderByComparator.getOrderByFields().length * 3));
3443                            }
3444                            else {
3445                                    query = new StringBundler(3);
3446                            }
3447    
3448                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3449    
3450                            boolean bindStructureId = false;
3451    
3452                            if (structureId == null) {
3453                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
3454                            }
3455                            else if (structureId.equals(StringPool.BLANK)) {
3456                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
3457                            }
3458                            else {
3459                                    bindStructureId = true;
3460    
3461                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
3462                            }
3463    
3464                            if (orderByComparator != null) {
3465                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3466                                            orderByComparator);
3467                            }
3468                            else
3469                             if (pagination) {
3470                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3471                            }
3472    
3473                            String sql = query.toString();
3474    
3475                            Session session = null;
3476    
3477                            try {
3478                                    session = openSession();
3479    
3480                                    Query q = session.createQuery(sql);
3481    
3482                                    QueryPos qPos = QueryPos.getInstance(q);
3483    
3484                                    if (bindStructureId) {
3485                                            qPos.add(structureId);
3486                                    }
3487    
3488                                    if (!pagination) {
3489                                            list = (List<JournalArticle>)QueryUtil.list(q,
3490                                                            getDialect(), start, end, false);
3491    
3492                                            Collections.sort(list);
3493    
3494                                            list = new UnmodifiableList<JournalArticle>(list);
3495                                    }
3496                                    else {
3497                                            list = (List<JournalArticle>)QueryUtil.list(q,
3498                                                            getDialect(), start, end);
3499                                    }
3500    
3501                                    cacheResult(list);
3502    
3503                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3504                            }
3505                            catch (Exception e) {
3506                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3507    
3508                                    throw processException(e);
3509                            }
3510                            finally {
3511                                    closeSession(session);
3512                            }
3513                    }
3514    
3515                    return list;
3516            }
3517    
3518            /**
3519             * Returns the first journal article in the ordered set where structureId = &#63;.
3520             *
3521             * @param structureId the structure ID
3522             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3523             * @return the first matching journal article
3524             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3525             * @throws SystemException if a system exception occurred
3526             */
3527            @Override
3528            public JournalArticle findByStructureId_First(String structureId,
3529                    OrderByComparator orderByComparator)
3530                    throws NoSuchArticleException, SystemException {
3531                    JournalArticle journalArticle = fetchByStructureId_First(structureId,
3532                                    orderByComparator);
3533    
3534                    if (journalArticle != null) {
3535                            return journalArticle;
3536                    }
3537    
3538                    StringBundler msg = new StringBundler(4);
3539    
3540                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3541    
3542                    msg.append("structureId=");
3543                    msg.append(structureId);
3544    
3545                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3546    
3547                    throw new NoSuchArticleException(msg.toString());
3548            }
3549    
3550            /**
3551             * Returns the first journal article in the ordered set where structureId = &#63;.
3552             *
3553             * @param structureId the structure ID
3554             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3555             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
3556             * @throws SystemException if a system exception occurred
3557             */
3558            @Override
3559            public JournalArticle fetchByStructureId_First(String structureId,
3560                    OrderByComparator orderByComparator) throws SystemException {
3561                    List<JournalArticle> list = findByStructureId(structureId, 0, 1,
3562                                    orderByComparator);
3563    
3564                    if (!list.isEmpty()) {
3565                            return list.get(0);
3566                    }
3567    
3568                    return null;
3569            }
3570    
3571            /**
3572             * Returns the last journal article in the ordered set where structureId = &#63;.
3573             *
3574             * @param structureId the structure ID
3575             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3576             * @return the last matching journal article
3577             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3578             * @throws SystemException if a system exception occurred
3579             */
3580            @Override
3581            public JournalArticle findByStructureId_Last(String structureId,
3582                    OrderByComparator orderByComparator)
3583                    throws NoSuchArticleException, SystemException {
3584                    JournalArticle journalArticle = fetchByStructureId_Last(structureId,
3585                                    orderByComparator);
3586    
3587                    if (journalArticle != null) {
3588                            return journalArticle;
3589                    }
3590    
3591                    StringBundler msg = new StringBundler(4);
3592    
3593                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3594    
3595                    msg.append("structureId=");
3596                    msg.append(structureId);
3597    
3598                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3599    
3600                    throw new NoSuchArticleException(msg.toString());
3601            }
3602    
3603            /**
3604             * Returns the last journal article in the ordered set where structureId = &#63;.
3605             *
3606             * @param structureId the structure ID
3607             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3608             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
3609             * @throws SystemException if a system exception occurred
3610             */
3611            @Override
3612            public JournalArticle fetchByStructureId_Last(String structureId,
3613                    OrderByComparator orderByComparator) throws SystemException {
3614                    int count = countByStructureId(structureId);
3615    
3616                    if (count == 0) {
3617                            return null;
3618                    }
3619    
3620                    List<JournalArticle> list = findByStructureId(structureId, count - 1,
3621                                    count, orderByComparator);
3622    
3623                    if (!list.isEmpty()) {
3624                            return list.get(0);
3625                    }
3626    
3627                    return null;
3628            }
3629    
3630            /**
3631             * Returns the journal articles before and after the current journal article in the ordered set where structureId = &#63;.
3632             *
3633             * @param id the primary key of the current journal article
3634             * @param structureId the structure ID
3635             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3636             * @return the previous, current, and next journal article
3637             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
3638             * @throws SystemException if a system exception occurred
3639             */
3640            @Override
3641            public JournalArticle[] findByStructureId_PrevAndNext(long id,
3642                    String structureId, OrderByComparator orderByComparator)
3643                    throws NoSuchArticleException, SystemException {
3644                    JournalArticle journalArticle = findByPrimaryKey(id);
3645    
3646                    Session session = null;
3647    
3648                    try {
3649                            session = openSession();
3650    
3651                            JournalArticle[] array = new JournalArticleImpl[3];
3652    
3653                            array[0] = getByStructureId_PrevAndNext(session, journalArticle,
3654                                            structureId, orderByComparator, true);
3655    
3656                            array[1] = journalArticle;
3657    
3658                            array[2] = getByStructureId_PrevAndNext(session, journalArticle,
3659                                            structureId, orderByComparator, false);
3660    
3661                            return array;
3662                    }
3663                    catch (Exception e) {
3664                            throw processException(e);
3665                    }
3666                    finally {
3667                            closeSession(session);
3668                    }
3669            }
3670    
3671            protected JournalArticle getByStructureId_PrevAndNext(Session session,
3672                    JournalArticle journalArticle, String structureId,
3673                    OrderByComparator orderByComparator, boolean previous) {
3674                    StringBundler query = null;
3675    
3676                    if (orderByComparator != null) {
3677                            query = new StringBundler(6 +
3678                                            (orderByComparator.getOrderByFields().length * 6));
3679                    }
3680                    else {
3681                            query = new StringBundler(3);
3682                    }
3683    
3684                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3685    
3686                    boolean bindStructureId = false;
3687    
3688                    if (structureId == null) {
3689                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
3690                    }
3691                    else if (structureId.equals(StringPool.BLANK)) {
3692                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
3693                    }
3694                    else {
3695                            bindStructureId = true;
3696    
3697                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
3698                    }
3699    
3700                    if (orderByComparator != null) {
3701                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3702    
3703                            if (orderByConditionFields.length > 0) {
3704                                    query.append(WHERE_AND);
3705                            }
3706    
3707                            for (int i = 0; i < orderByConditionFields.length; i++) {
3708                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3709                                    query.append(orderByConditionFields[i]);
3710    
3711                                    if ((i + 1) < orderByConditionFields.length) {
3712                                            if (orderByComparator.isAscending() ^ previous) {
3713                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3714                                            }
3715                                            else {
3716                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3717                                            }
3718                                    }
3719                                    else {
3720                                            if (orderByComparator.isAscending() ^ previous) {
3721                                                    query.append(WHERE_GREATER_THAN);
3722                                            }
3723                                            else {
3724                                                    query.append(WHERE_LESSER_THAN);
3725                                            }
3726                                    }
3727                            }
3728    
3729                            query.append(ORDER_BY_CLAUSE);
3730    
3731                            String[] orderByFields = orderByComparator.getOrderByFields();
3732    
3733                            for (int i = 0; i < orderByFields.length; i++) {
3734                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3735                                    query.append(orderByFields[i]);
3736    
3737                                    if ((i + 1) < orderByFields.length) {
3738                                            if (orderByComparator.isAscending() ^ previous) {
3739                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3740                                            }
3741                                            else {
3742                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3743                                            }
3744                                    }
3745                                    else {
3746                                            if (orderByComparator.isAscending() ^ previous) {
3747                                                    query.append(ORDER_BY_ASC);
3748                                            }
3749                                            else {
3750                                                    query.append(ORDER_BY_DESC);
3751                                            }
3752                                    }
3753                            }
3754                    }
3755                    else {
3756                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3757                    }
3758    
3759                    String sql = query.toString();
3760    
3761                    Query q = session.createQuery(sql);
3762    
3763                    q.setFirstResult(0);
3764                    q.setMaxResults(2);
3765    
3766                    QueryPos qPos = QueryPos.getInstance(q);
3767    
3768                    if (bindStructureId) {
3769                            qPos.add(structureId);
3770                    }
3771    
3772                    if (orderByComparator != null) {
3773                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
3774    
3775                            for (Object value : values) {
3776                                    qPos.add(value);
3777                            }
3778                    }
3779    
3780                    List<JournalArticle> list = q.list();
3781    
3782                    if (list.size() == 2) {
3783                            return list.get(1);
3784                    }
3785                    else {
3786                            return null;
3787                    }
3788            }
3789    
3790            /**
3791             * Returns all the journal articles where structureId = any &#63;.
3792             *
3793             * <p>
3794             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3795             * </p>
3796             *
3797             * @param structureIds the structure IDs
3798             * @return the matching journal articles
3799             * @throws SystemException if a system exception occurred
3800             */
3801            @Override
3802            public List<JournalArticle> findByStructureId(String[] structureIds)
3803                    throws SystemException {
3804                    return findByStructureId(structureIds, QueryUtil.ALL_POS,
3805                            QueryUtil.ALL_POS, null);
3806            }
3807    
3808            /**
3809             * Returns a range of all the journal articles where structureId = any &#63;.
3810             *
3811             * <p>
3812             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3813             * </p>
3814             *
3815             * @param structureIds the structure IDs
3816             * @param start the lower bound of the range of journal articles
3817             * @param end the upper bound of the range of journal articles (not inclusive)
3818             * @return the range of matching journal articles
3819             * @throws SystemException if a system exception occurred
3820             */
3821            @Override
3822            public List<JournalArticle> findByStructureId(String[] structureIds,
3823                    int start, int end) throws SystemException {
3824                    return findByStructureId(structureIds, start, end, null);
3825            }
3826    
3827            /**
3828             * Returns an ordered range of all the journal articles where structureId = any &#63;.
3829             *
3830             * <p>
3831             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3832             * </p>
3833             *
3834             * @param structureIds the structure IDs
3835             * @param start the lower bound of the range of journal articles
3836             * @param end the upper bound of the range of journal articles (not inclusive)
3837             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3838             * @return the ordered range of matching journal articles
3839             * @throws SystemException if a system exception occurred
3840             */
3841            @Override
3842            public List<JournalArticle> findByStructureId(String[] structureIds,
3843                    int start, int end, OrderByComparator orderByComparator)
3844                    throws SystemException {
3845                    if ((structureIds != null) && (structureIds.length == 1)) {
3846                            return findByStructureId(structureIds[0], start, end,
3847                                    orderByComparator);
3848                    }
3849    
3850                    boolean pagination = true;
3851                    Object[] finderArgs = null;
3852    
3853                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3854                                    (orderByComparator == null)) {
3855                            pagination = false;
3856                            finderArgs = new Object[] { StringUtil.merge(structureIds) };
3857                    }
3858                    else {
3859                            finderArgs = new Object[] {
3860                                            StringUtil.merge(structureIds),
3861                                            
3862                                            start, end, orderByComparator
3863                                    };
3864                    }
3865    
3866                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID,
3867                                    finderArgs, this);
3868    
3869                    if ((list != null) && !list.isEmpty()) {
3870                            for (JournalArticle journalArticle : list) {
3871                                    if (!ArrayUtil.contains(structureIds,
3872                                                            journalArticle.getStructureId())) {
3873                                            list = null;
3874    
3875                                            break;
3876                                    }
3877                            }
3878                    }
3879    
3880                    if (list == null) {
3881                            StringBundler query = new StringBundler();
3882    
3883                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3884    
3885                            boolean conjunctionable = false;
3886    
3887                            if ((structureIds == null) || (structureIds.length > 0)) {
3888                                    if (conjunctionable) {
3889                                            query.append(WHERE_AND);
3890                                    }
3891    
3892                                    query.append(StringPool.OPEN_PARENTHESIS);
3893    
3894                                    for (int i = 0; i < structureIds.length; i++) {
3895                                            String structureId = structureIds[i];
3896    
3897                                            if (structureId == null) {
3898                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_4);
3899                                            }
3900                                            else if (structureId.equals(StringPool.BLANK)) {
3901                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_6);
3902                                            }
3903                                            else {
3904                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_5);
3905                                            }
3906    
3907                                            if ((i + 1) < structureIds.length) {
3908                                                    query.append(WHERE_OR);
3909                                            }
3910                                    }
3911    
3912                                    query.append(StringPool.CLOSE_PARENTHESIS);
3913    
3914                                    conjunctionable = true;
3915                            }
3916    
3917                            if (orderByComparator != null) {
3918                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3919                                            orderByComparator);
3920                            }
3921                            else
3922                             if (pagination) {
3923                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3924                            }
3925    
3926                            String sql = query.toString();
3927    
3928                            Session session = null;
3929    
3930                            try {
3931                                    session = openSession();
3932    
3933                                    Query q = session.createQuery(sql);
3934    
3935                                    QueryPos qPos = QueryPos.getInstance(q);
3936    
3937                                    if (structureIds != null) {
3938                                            qPos.add(structureIds);
3939                                    }
3940    
3941                                    if (!pagination) {
3942                                            list = (List<JournalArticle>)QueryUtil.list(q,
3943                                                            getDialect(), start, end, false);
3944    
3945                                            Collections.sort(list);
3946    
3947                                            list = new UnmodifiableList<JournalArticle>(list);
3948                                    }
3949                                    else {
3950                                            list = (List<JournalArticle>)QueryUtil.list(q,
3951                                                            getDialect(), start, end);
3952                                    }
3953    
3954                                    cacheResult(list);
3955    
3956                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID,
3957                                            finderArgs, list);
3958                            }
3959                            catch (Exception e) {
3960                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID,
3961                                            finderArgs);
3962    
3963                                    throw processException(e);
3964                            }
3965                            finally {
3966                                    closeSession(session);
3967                            }
3968                    }
3969    
3970                    return list;
3971            }
3972    
3973            /**
3974             * Removes all the journal articles where structureId = &#63; from the database.
3975             *
3976             * @param structureId the structure ID
3977             * @throws SystemException if a system exception occurred
3978             */
3979            @Override
3980            public void removeByStructureId(String structureId)
3981                    throws SystemException {
3982                    for (JournalArticle journalArticle : findByStructureId(structureId,
3983                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3984                            remove(journalArticle);
3985                    }
3986            }
3987    
3988            /**
3989             * Returns the number of journal articles where structureId = &#63;.
3990             *
3991             * @param structureId the structure ID
3992             * @return the number of matching journal articles
3993             * @throws SystemException if a system exception occurred
3994             */
3995            @Override
3996            public int countByStructureId(String structureId) throws SystemException {
3997                    FinderPath finderPath = FINDER_PATH_COUNT_BY_STRUCTUREID;
3998    
3999                    Object[] finderArgs = new Object[] { structureId };
4000    
4001                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4002                                    this);
4003    
4004                    if (count == null) {
4005                            StringBundler query = new StringBundler(2);
4006    
4007                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
4008    
4009                            boolean bindStructureId = false;
4010    
4011                            if (structureId == null) {
4012                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
4013                            }
4014                            else if (structureId.equals(StringPool.BLANK)) {
4015                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
4016                            }
4017                            else {
4018                                    bindStructureId = true;
4019    
4020                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
4021                            }
4022    
4023                            String sql = query.toString();
4024    
4025                            Session session = null;
4026    
4027                            try {
4028                                    session = openSession();
4029    
4030                                    Query q = session.createQuery(sql);
4031    
4032                                    QueryPos qPos = QueryPos.getInstance(q);
4033    
4034                                    if (bindStructureId) {
4035                                            qPos.add(structureId);
4036                                    }
4037    
4038                                    count = (Long)q.uniqueResult();
4039    
4040                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4041                            }
4042                            catch (Exception e) {
4043                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4044    
4045                                    throw processException(e);
4046                            }
4047                            finally {
4048                                    closeSession(session);
4049                            }
4050                    }
4051    
4052                    return count.intValue();
4053            }
4054    
4055            /**
4056             * Returns the number of journal articles where structureId = any &#63;.
4057             *
4058             * @param structureIds the structure IDs
4059             * @return the number of matching journal articles
4060             * @throws SystemException if a system exception occurred
4061             */
4062            @Override
4063            public int countByStructureId(String[] structureIds)
4064                    throws SystemException {
4065                    Object[] finderArgs = new Object[] { StringUtil.merge(structureIds) };
4066    
4067                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_STRUCTUREID,
4068                                    finderArgs, this);
4069    
4070                    if (count == null) {
4071                            StringBundler query = new StringBundler();
4072    
4073                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
4074    
4075                            boolean conjunctionable = false;
4076    
4077                            if ((structureIds == null) || (structureIds.length > 0)) {
4078                                    if (conjunctionable) {
4079                                            query.append(WHERE_AND);
4080                                    }
4081    
4082                                    query.append(StringPool.OPEN_PARENTHESIS);
4083    
4084                                    for (int i = 0; i < structureIds.length; i++) {
4085                                            String structureId = structureIds[i];
4086    
4087                                            if (structureId == null) {
4088                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_4);
4089                                            }
4090                                            else if (structureId.equals(StringPool.BLANK)) {
4091                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_6);
4092                                            }
4093                                            else {
4094                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_5);
4095                                            }
4096    
4097                                            if ((i + 1) < structureIds.length) {
4098                                                    query.append(WHERE_OR);
4099                                            }
4100                                    }
4101    
4102                                    query.append(StringPool.CLOSE_PARENTHESIS);
4103    
4104                                    conjunctionable = true;
4105                            }
4106    
4107                            String sql = query.toString();
4108    
4109                            Session session = null;
4110    
4111                            try {
4112                                    session = openSession();
4113    
4114                                    Query q = session.createQuery(sql);
4115    
4116                                    QueryPos qPos = QueryPos.getInstance(q);
4117    
4118                                    if (structureIds != null) {
4119                                            qPos.add(structureIds);
4120                                    }
4121    
4122                                    count = (Long)q.uniqueResult();
4123    
4124                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_STRUCTUREID,
4125                                            finderArgs, count);
4126                            }
4127                            catch (Exception e) {
4128                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_STRUCTUREID,
4129                                            finderArgs);
4130    
4131                                    throw processException(e);
4132                            }
4133                            finally {
4134                                    closeSession(session);
4135                            }
4136                    }
4137    
4138                    return count.intValue();
4139            }
4140    
4141            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
4142            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2 = "journalArticle.structureId = ?";
4143            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = '')";
4144            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_4 = "(" +
4145                    removeConjunction(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1) + ")";
4146            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_5 = "(" +
4147                    removeConjunction(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2) + ")";
4148            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_6 = "(" +
4149                    removeConjunction(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3) + ")";
4150            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_TEMPLATEID =
4151                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4152                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4153                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
4154                            "findByTemplateId",
4155                            new String[] {
4156                                    String.class.getName(),
4157                                    
4158                            Integer.class.getName(), Integer.class.getName(),
4159                                    OrderByComparator.class.getName()
4160                            });
4161            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID =
4162                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4163                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4164                            JournalArticleImpl.class,
4165                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByTemplateId",
4166                            new String[] { String.class.getName() },
4167                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK |
4168                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
4169                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
4170            public static final FinderPath FINDER_PATH_COUNT_BY_TEMPLATEID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4171                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
4172                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByTemplateId",
4173                            new String[] { String.class.getName() });
4174    
4175            /**
4176             * Returns all the journal articles where templateId = &#63;.
4177             *
4178             * @param templateId the template ID
4179             * @return the matching journal articles
4180             * @throws SystemException if a system exception occurred
4181             */
4182            @Override
4183            public List<JournalArticle> findByTemplateId(String templateId)
4184                    throws SystemException {
4185                    return findByTemplateId(templateId, QueryUtil.ALL_POS,
4186                            QueryUtil.ALL_POS, null);
4187            }
4188    
4189            /**
4190             * Returns a range of all the journal articles where templateId = &#63;.
4191             *
4192             * <p>
4193             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4194             * </p>
4195             *
4196             * @param templateId the template ID
4197             * @param start the lower bound of the range of journal articles
4198             * @param end the upper bound of the range of journal articles (not inclusive)
4199             * @return the range of matching journal articles
4200             * @throws SystemException if a system exception occurred
4201             */
4202            @Override
4203            public List<JournalArticle> findByTemplateId(String templateId, int start,
4204                    int end) throws SystemException {
4205                    return findByTemplateId(templateId, start, end, null);
4206            }
4207    
4208            /**
4209             * Returns an ordered range of all the journal articles where templateId = &#63;.
4210             *
4211             * <p>
4212             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4213             * </p>
4214             *
4215             * @param templateId the template ID
4216             * @param start the lower bound of the range of journal articles
4217             * @param end the upper bound of the range of journal articles (not inclusive)
4218             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4219             * @return the ordered range of matching journal articles
4220             * @throws SystemException if a system exception occurred
4221             */
4222            @Override
4223            public List<JournalArticle> findByTemplateId(String templateId, int start,
4224                    int end, OrderByComparator orderByComparator) throws SystemException {
4225                    boolean pagination = true;
4226                    FinderPath finderPath = null;
4227                    Object[] finderArgs = null;
4228    
4229                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4230                                    (orderByComparator == null)) {
4231                            pagination = false;
4232                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID;
4233                            finderArgs = new Object[] { templateId };
4234                    }
4235                    else {
4236                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_TEMPLATEID;
4237                            finderArgs = new Object[] { templateId, start, end, orderByComparator };
4238                    }
4239    
4240                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
4241                                    finderArgs, this);
4242    
4243                    if ((list != null) && !list.isEmpty()) {
4244                            for (JournalArticle journalArticle : list) {
4245                                    if (!Validator.equals(templateId, journalArticle.getTemplateId())) {
4246                                            list = null;
4247    
4248                                            break;
4249                                    }
4250                            }
4251                    }
4252    
4253                    if (list == null) {
4254                            StringBundler query = null;
4255    
4256                            if (orderByComparator != null) {
4257                                    query = new StringBundler(3 +
4258                                                    (orderByComparator.getOrderByFields().length * 3));
4259                            }
4260                            else {
4261                                    query = new StringBundler(3);
4262                            }
4263    
4264                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4265    
4266                            boolean bindTemplateId = false;
4267    
4268                            if (templateId == null) {
4269                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
4270                            }
4271                            else if (templateId.equals(StringPool.BLANK)) {
4272                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
4273                            }
4274                            else {
4275                                    bindTemplateId = true;
4276    
4277                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
4278                            }
4279    
4280                            if (orderByComparator != null) {
4281                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4282                                            orderByComparator);
4283                            }
4284                            else
4285                             if (pagination) {
4286                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4287                            }
4288    
4289                            String sql = query.toString();
4290    
4291                            Session session = null;
4292    
4293                            try {
4294                                    session = openSession();
4295    
4296                                    Query q = session.createQuery(sql);
4297    
4298                                    QueryPos qPos = QueryPos.getInstance(q);
4299    
4300                                    if (bindTemplateId) {
4301                                            qPos.add(templateId);
4302                                    }
4303    
4304                                    if (!pagination) {
4305                                            list = (List<JournalArticle>)QueryUtil.list(q,
4306                                                            getDialect(), start, end, false);
4307    
4308                                            Collections.sort(list);
4309    
4310                                            list = new UnmodifiableList<JournalArticle>(list);
4311                                    }
4312                                    else {
4313                                            list = (List<JournalArticle>)QueryUtil.list(q,
4314                                                            getDialect(), start, end);
4315                                    }
4316    
4317                                    cacheResult(list);
4318    
4319                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4320                            }
4321                            catch (Exception e) {
4322                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4323    
4324                                    throw processException(e);
4325                            }
4326                            finally {
4327                                    closeSession(session);
4328                            }
4329                    }
4330    
4331                    return list;
4332            }
4333    
4334            /**
4335             * Returns the first journal article in the ordered set where templateId = &#63;.
4336             *
4337             * @param templateId the template ID
4338             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4339             * @return the first matching journal article
4340             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4341             * @throws SystemException if a system exception occurred
4342             */
4343            @Override
4344            public JournalArticle findByTemplateId_First(String templateId,
4345                    OrderByComparator orderByComparator)
4346                    throws NoSuchArticleException, SystemException {
4347                    JournalArticle journalArticle = fetchByTemplateId_First(templateId,
4348                                    orderByComparator);
4349    
4350                    if (journalArticle != null) {
4351                            return journalArticle;
4352                    }
4353    
4354                    StringBundler msg = new StringBundler(4);
4355    
4356                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4357    
4358                    msg.append("templateId=");
4359                    msg.append(templateId);
4360    
4361                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4362    
4363                    throw new NoSuchArticleException(msg.toString());
4364            }
4365    
4366            /**
4367             * Returns the first journal article in the ordered set where templateId = &#63;.
4368             *
4369             * @param templateId the template ID
4370             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4371             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
4372             * @throws SystemException if a system exception occurred
4373             */
4374            @Override
4375            public JournalArticle fetchByTemplateId_First(String templateId,
4376                    OrderByComparator orderByComparator) throws SystemException {
4377                    List<JournalArticle> list = findByTemplateId(templateId, 0, 1,
4378                                    orderByComparator);
4379    
4380                    if (!list.isEmpty()) {
4381                            return list.get(0);
4382                    }
4383    
4384                    return null;
4385            }
4386    
4387            /**
4388             * Returns the last journal article in the ordered set where templateId = &#63;.
4389             *
4390             * @param templateId the template ID
4391             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4392             * @return the last matching journal article
4393             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4394             * @throws SystemException if a system exception occurred
4395             */
4396            @Override
4397            public JournalArticle findByTemplateId_Last(String templateId,
4398                    OrderByComparator orderByComparator)
4399                    throws NoSuchArticleException, SystemException {
4400                    JournalArticle journalArticle = fetchByTemplateId_Last(templateId,
4401                                    orderByComparator);
4402    
4403                    if (journalArticle != null) {
4404                            return journalArticle;
4405                    }
4406    
4407                    StringBundler msg = new StringBundler(4);
4408    
4409                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4410    
4411                    msg.append("templateId=");
4412                    msg.append(templateId);
4413    
4414                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4415    
4416                    throw new NoSuchArticleException(msg.toString());
4417            }
4418    
4419            /**
4420             * Returns the last journal article in the ordered set where templateId = &#63;.
4421             *
4422             * @param templateId the template ID
4423             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4424             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
4425             * @throws SystemException if a system exception occurred
4426             */
4427            @Override
4428            public JournalArticle fetchByTemplateId_Last(String templateId,
4429                    OrderByComparator orderByComparator) throws SystemException {
4430                    int count = countByTemplateId(templateId);
4431    
4432                    if (count == 0) {
4433                            return null;
4434                    }
4435    
4436                    List<JournalArticle> list = findByTemplateId(templateId, count - 1,
4437                                    count, orderByComparator);
4438    
4439                    if (!list.isEmpty()) {
4440                            return list.get(0);
4441                    }
4442    
4443                    return null;
4444            }
4445    
4446            /**
4447             * Returns the journal articles before and after the current journal article in the ordered set where templateId = &#63;.
4448             *
4449             * @param id the primary key of the current journal article
4450             * @param templateId the template ID
4451             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4452             * @return the previous, current, and next journal article
4453             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
4454             * @throws SystemException if a system exception occurred
4455             */
4456            @Override
4457            public JournalArticle[] findByTemplateId_PrevAndNext(long id,
4458                    String templateId, OrderByComparator orderByComparator)
4459                    throws NoSuchArticleException, SystemException {
4460                    JournalArticle journalArticle = findByPrimaryKey(id);
4461    
4462                    Session session = null;
4463    
4464                    try {
4465                            session = openSession();
4466    
4467                            JournalArticle[] array = new JournalArticleImpl[3];
4468    
4469                            array[0] = getByTemplateId_PrevAndNext(session, journalArticle,
4470                                            templateId, orderByComparator, true);
4471    
4472                            array[1] = journalArticle;
4473    
4474                            array[2] = getByTemplateId_PrevAndNext(session, journalArticle,
4475                                            templateId, orderByComparator, false);
4476    
4477                            return array;
4478                    }
4479                    catch (Exception e) {
4480                            throw processException(e);
4481                    }
4482                    finally {
4483                            closeSession(session);
4484                    }
4485            }
4486    
4487            protected JournalArticle getByTemplateId_PrevAndNext(Session session,
4488                    JournalArticle journalArticle, String templateId,
4489                    OrderByComparator orderByComparator, boolean previous) {
4490                    StringBundler query = null;
4491    
4492                    if (orderByComparator != null) {
4493                            query = new StringBundler(6 +
4494                                            (orderByComparator.getOrderByFields().length * 6));
4495                    }
4496                    else {
4497                            query = new StringBundler(3);
4498                    }
4499    
4500                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4501    
4502                    boolean bindTemplateId = false;
4503    
4504                    if (templateId == null) {
4505                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
4506                    }
4507                    else if (templateId.equals(StringPool.BLANK)) {
4508                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
4509                    }
4510                    else {
4511                            bindTemplateId = true;
4512    
4513                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
4514                    }
4515    
4516                    if (orderByComparator != null) {
4517                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4518    
4519                            if (orderByConditionFields.length > 0) {
4520                                    query.append(WHERE_AND);
4521                            }
4522    
4523                            for (int i = 0; i < orderByConditionFields.length; i++) {
4524                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4525                                    query.append(orderByConditionFields[i]);
4526    
4527                                    if ((i + 1) < orderByConditionFields.length) {
4528                                            if (orderByComparator.isAscending() ^ previous) {
4529                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4530                                            }
4531                                            else {
4532                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4533                                            }
4534                                    }
4535                                    else {
4536                                            if (orderByComparator.isAscending() ^ previous) {
4537                                                    query.append(WHERE_GREATER_THAN);
4538                                            }
4539                                            else {
4540                                                    query.append(WHERE_LESSER_THAN);
4541                                            }
4542                                    }
4543                            }
4544    
4545                            query.append(ORDER_BY_CLAUSE);
4546    
4547                            String[] orderByFields = orderByComparator.getOrderByFields();
4548    
4549                            for (int i = 0; i < orderByFields.length; i++) {
4550                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4551                                    query.append(orderByFields[i]);
4552    
4553                                    if ((i + 1) < orderByFields.length) {
4554                                            if (orderByComparator.isAscending() ^ previous) {
4555                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4556                                            }
4557                                            else {
4558                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4559                                            }
4560                                    }
4561                                    else {
4562                                            if (orderByComparator.isAscending() ^ previous) {
4563                                                    query.append(ORDER_BY_ASC);
4564                                            }
4565                                            else {
4566                                                    query.append(ORDER_BY_DESC);
4567                                            }
4568                                    }
4569                            }
4570                    }
4571                    else {
4572                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4573                    }
4574    
4575                    String sql = query.toString();
4576    
4577                    Query q = session.createQuery(sql);
4578    
4579                    q.setFirstResult(0);
4580                    q.setMaxResults(2);
4581    
4582                    QueryPos qPos = QueryPos.getInstance(q);
4583    
4584                    if (bindTemplateId) {
4585                            qPos.add(templateId);
4586                    }
4587    
4588                    if (orderByComparator != null) {
4589                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
4590    
4591                            for (Object value : values) {
4592                                    qPos.add(value);
4593                            }
4594                    }
4595    
4596                    List<JournalArticle> list = q.list();
4597    
4598                    if (list.size() == 2) {
4599                            return list.get(1);
4600                    }
4601                    else {
4602                            return null;
4603                    }
4604            }
4605    
4606            /**
4607             * Removes all the journal articles where templateId = &#63; from the database.
4608             *
4609             * @param templateId the template ID
4610             * @throws SystemException if a system exception occurred
4611             */
4612            @Override
4613            public void removeByTemplateId(String templateId) throws SystemException {
4614                    for (JournalArticle journalArticle : findByTemplateId(templateId,
4615                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4616                            remove(journalArticle);
4617                    }
4618            }
4619    
4620            /**
4621             * Returns the number of journal articles where templateId = &#63;.
4622             *
4623             * @param templateId the template ID
4624             * @return the number of matching journal articles
4625             * @throws SystemException if a system exception occurred
4626             */
4627            @Override
4628            public int countByTemplateId(String templateId) throws SystemException {
4629                    FinderPath finderPath = FINDER_PATH_COUNT_BY_TEMPLATEID;
4630    
4631                    Object[] finderArgs = new Object[] { templateId };
4632    
4633                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4634                                    this);
4635    
4636                    if (count == null) {
4637                            StringBundler query = new StringBundler(2);
4638    
4639                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
4640    
4641                            boolean bindTemplateId = false;
4642    
4643                            if (templateId == null) {
4644                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
4645                            }
4646                            else if (templateId.equals(StringPool.BLANK)) {
4647                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
4648                            }
4649                            else {
4650                                    bindTemplateId = true;
4651    
4652                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
4653                            }
4654    
4655                            String sql = query.toString();
4656    
4657                            Session session = null;
4658    
4659                            try {
4660                                    session = openSession();
4661    
4662                                    Query q = session.createQuery(sql);
4663    
4664                                    QueryPos qPos = QueryPos.getInstance(q);
4665    
4666                                    if (bindTemplateId) {
4667                                            qPos.add(templateId);
4668                                    }
4669    
4670                                    count = (Long)q.uniqueResult();
4671    
4672                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4673                            }
4674                            catch (Exception e) {
4675                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4676    
4677                                    throw processException(e);
4678                            }
4679                            finally {
4680                                    closeSession(session);
4681                            }
4682                    }
4683    
4684                    return count.intValue();
4685            }
4686    
4687            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
4688            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2 = "journalArticle.templateId = ?";
4689            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = '')";
4690            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTUUID =
4691                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4692                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4693                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
4694                            "findByLayoutUuid",
4695                            new String[] {
4696                                    String.class.getName(),
4697                                    
4698                            Integer.class.getName(), Integer.class.getName(),
4699                                    OrderByComparator.class.getName()
4700                            });
4701            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID =
4702                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4703                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4704                            JournalArticleImpl.class,
4705                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByLayoutUuid",
4706                            new String[] { String.class.getName() },
4707                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK |
4708                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
4709                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
4710            public static final FinderPath FINDER_PATH_COUNT_BY_LAYOUTUUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4711                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
4712                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByLayoutUuid",
4713                            new String[] { String.class.getName() });
4714    
4715            /**
4716             * Returns all the journal articles where layoutUuid = &#63;.
4717             *
4718             * @param layoutUuid the layout uuid
4719             * @return the matching journal articles
4720             * @throws SystemException if a system exception occurred
4721             */
4722            @Override
4723            public List<JournalArticle> findByLayoutUuid(String layoutUuid)
4724                    throws SystemException {
4725                    return findByLayoutUuid(layoutUuid, QueryUtil.ALL_POS,
4726                            QueryUtil.ALL_POS, null);
4727            }
4728    
4729            /**
4730             * Returns a range of all the journal articles where layoutUuid = &#63;.
4731             *
4732             * <p>
4733             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4734             * </p>
4735             *
4736             * @param layoutUuid the layout uuid
4737             * @param start the lower bound of the range of journal articles
4738             * @param end the upper bound of the range of journal articles (not inclusive)
4739             * @return the range of matching journal articles
4740             * @throws SystemException if a system exception occurred
4741             */
4742            @Override
4743            public List<JournalArticle> findByLayoutUuid(String layoutUuid, int start,
4744                    int end) throws SystemException {
4745                    return findByLayoutUuid(layoutUuid, start, end, null);
4746            }
4747    
4748            /**
4749             * Returns an ordered range of all the journal articles where layoutUuid = &#63;.
4750             *
4751             * <p>
4752             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4753             * </p>
4754             *
4755             * @param layoutUuid the layout uuid
4756             * @param start the lower bound of the range of journal articles
4757             * @param end the upper bound of the range of journal articles (not inclusive)
4758             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4759             * @return the ordered range of matching journal articles
4760             * @throws SystemException if a system exception occurred
4761             */
4762            @Override
4763            public List<JournalArticle> findByLayoutUuid(String layoutUuid, int start,
4764                    int end, OrderByComparator orderByComparator) throws SystemException {
4765                    boolean pagination = true;
4766                    FinderPath finderPath = null;
4767                    Object[] finderArgs = null;
4768    
4769                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4770                                    (orderByComparator == null)) {
4771                            pagination = false;
4772                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID;
4773                            finderArgs = new Object[] { layoutUuid };
4774                    }
4775                    else {
4776                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTUUID;
4777                            finderArgs = new Object[] { layoutUuid, start, end, orderByComparator };
4778                    }
4779    
4780                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
4781                                    finderArgs, this);
4782    
4783                    if ((list != null) && !list.isEmpty()) {
4784                            for (JournalArticle journalArticle : list) {
4785                                    if (!Validator.equals(layoutUuid, journalArticle.getLayoutUuid())) {
4786                                            list = null;
4787    
4788                                            break;
4789                                    }
4790                            }
4791                    }
4792    
4793                    if (list == null) {
4794                            StringBundler query = null;
4795    
4796                            if (orderByComparator != null) {
4797                                    query = new StringBundler(3 +
4798                                                    (orderByComparator.getOrderByFields().length * 3));
4799                            }
4800                            else {
4801                                    query = new StringBundler(3);
4802                            }
4803    
4804                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4805    
4806                            boolean bindLayoutUuid = false;
4807    
4808                            if (layoutUuid == null) {
4809                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
4810                            }
4811                            else if (layoutUuid.equals(StringPool.BLANK)) {
4812                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
4813                            }
4814                            else {
4815                                    bindLayoutUuid = true;
4816    
4817                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
4818                            }
4819    
4820                            if (orderByComparator != null) {
4821                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4822                                            orderByComparator);
4823                            }
4824                            else
4825                             if (pagination) {
4826                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4827                            }
4828    
4829                            String sql = query.toString();
4830    
4831                            Session session = null;
4832    
4833                            try {
4834                                    session = openSession();
4835    
4836                                    Query q = session.createQuery(sql);
4837    
4838                                    QueryPos qPos = QueryPos.getInstance(q);
4839    
4840                                    if (bindLayoutUuid) {
4841                                            qPos.add(layoutUuid);
4842                                    }
4843    
4844                                    if (!pagination) {
4845                                            list = (List<JournalArticle>)QueryUtil.list(q,
4846                                                            getDialect(), start, end, false);
4847    
4848                                            Collections.sort(list);
4849    
4850                                            list = new UnmodifiableList<JournalArticle>(list);
4851                                    }
4852                                    else {
4853                                            list = (List<JournalArticle>)QueryUtil.list(q,
4854                                                            getDialect(), start, end);
4855                                    }
4856    
4857                                    cacheResult(list);
4858    
4859                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4860                            }
4861                            catch (Exception e) {
4862                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4863    
4864                                    throw processException(e);
4865                            }
4866                            finally {
4867                                    closeSession(session);
4868                            }
4869                    }
4870    
4871                    return list;
4872            }
4873    
4874            /**
4875             * Returns the first journal article in the ordered set where layoutUuid = &#63;.
4876             *
4877             * @param layoutUuid the layout uuid
4878             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4879             * @return the first matching journal article
4880             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4881             * @throws SystemException if a system exception occurred
4882             */
4883            @Override
4884            public JournalArticle findByLayoutUuid_First(String layoutUuid,
4885                    OrderByComparator orderByComparator)
4886                    throws NoSuchArticleException, SystemException {
4887                    JournalArticle journalArticle = fetchByLayoutUuid_First(layoutUuid,
4888                                    orderByComparator);
4889    
4890                    if (journalArticle != null) {
4891                            return journalArticle;
4892                    }
4893    
4894                    StringBundler msg = new StringBundler(4);
4895    
4896                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4897    
4898                    msg.append("layoutUuid=");
4899                    msg.append(layoutUuid);
4900    
4901                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4902    
4903                    throw new NoSuchArticleException(msg.toString());
4904            }
4905    
4906            /**
4907             * Returns the first journal article in the ordered set where layoutUuid = &#63;.
4908             *
4909             * @param layoutUuid the layout uuid
4910             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4911             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
4912             * @throws SystemException if a system exception occurred
4913             */
4914            @Override
4915            public JournalArticle fetchByLayoutUuid_First(String layoutUuid,
4916                    OrderByComparator orderByComparator) throws SystemException {
4917                    List<JournalArticle> list = findByLayoutUuid(layoutUuid, 0, 1,
4918                                    orderByComparator);
4919    
4920                    if (!list.isEmpty()) {
4921                            return list.get(0);
4922                    }
4923    
4924                    return null;
4925            }
4926    
4927            /**
4928             * Returns the last journal article in the ordered set where layoutUuid = &#63;.
4929             *
4930             * @param layoutUuid the layout uuid
4931             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4932             * @return the last matching journal article
4933             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4934             * @throws SystemException if a system exception occurred
4935             */
4936            @Override
4937            public JournalArticle findByLayoutUuid_Last(String layoutUuid,
4938                    OrderByComparator orderByComparator)
4939                    throws NoSuchArticleException, SystemException {
4940                    JournalArticle journalArticle = fetchByLayoutUuid_Last(layoutUuid,
4941                                    orderByComparator);
4942    
4943                    if (journalArticle != null) {
4944                            return journalArticle;
4945                    }
4946    
4947                    StringBundler msg = new StringBundler(4);
4948    
4949                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4950    
4951                    msg.append("layoutUuid=");
4952                    msg.append(layoutUuid);
4953    
4954                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4955    
4956                    throw new NoSuchArticleException(msg.toString());
4957            }
4958    
4959            /**
4960             * Returns the last journal article in the ordered set where layoutUuid = &#63;.
4961             *
4962             * @param layoutUuid the layout uuid
4963             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4964             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
4965             * @throws SystemException if a system exception occurred
4966             */
4967            @Override
4968            public JournalArticle fetchByLayoutUuid_Last(String layoutUuid,
4969                    OrderByComparator orderByComparator) throws SystemException {
4970                    int count = countByLayoutUuid(layoutUuid);
4971    
4972                    if (count == 0) {
4973                            return null;
4974                    }
4975    
4976                    List<JournalArticle> list = findByLayoutUuid(layoutUuid, count - 1,
4977                                    count, orderByComparator);
4978    
4979                    if (!list.isEmpty()) {
4980                            return list.get(0);
4981                    }
4982    
4983                    return null;
4984            }
4985    
4986            /**
4987             * Returns the journal articles before and after the current journal article in the ordered set where layoutUuid = &#63;.
4988             *
4989             * @param id the primary key of the current journal article
4990             * @param layoutUuid the layout uuid
4991             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4992             * @return the previous, current, and next journal article
4993             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
4994             * @throws SystemException if a system exception occurred
4995             */
4996            @Override
4997            public JournalArticle[] findByLayoutUuid_PrevAndNext(long id,
4998                    String layoutUuid, OrderByComparator orderByComparator)
4999                    throws NoSuchArticleException, SystemException {
5000                    JournalArticle journalArticle = findByPrimaryKey(id);
5001    
5002                    Session session = null;
5003    
5004                    try {
5005                            session = openSession();
5006    
5007                            JournalArticle[] array = new JournalArticleImpl[3];
5008    
5009                            array[0] = getByLayoutUuid_PrevAndNext(session, journalArticle,
5010                                            layoutUuid, orderByComparator, true);
5011    
5012                            array[1] = journalArticle;
5013    
5014                            array[2] = getByLayoutUuid_PrevAndNext(session, journalArticle,
5015                                            layoutUuid, orderByComparator, false);
5016    
5017                            return array;
5018                    }
5019                    catch (Exception e) {
5020                            throw processException(e);
5021                    }
5022                    finally {
5023                            closeSession(session);
5024                    }
5025            }
5026    
5027            protected JournalArticle getByLayoutUuid_PrevAndNext(Session session,
5028                    JournalArticle journalArticle, String layoutUuid,
5029                    OrderByComparator orderByComparator, boolean previous) {
5030                    StringBundler query = null;
5031    
5032                    if (orderByComparator != null) {
5033                            query = new StringBundler(6 +
5034                                            (orderByComparator.getOrderByFields().length * 6));
5035                    }
5036                    else {
5037                            query = new StringBundler(3);
5038                    }
5039    
5040                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5041    
5042                    boolean bindLayoutUuid = false;
5043    
5044                    if (layoutUuid == null) {
5045                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
5046                    }
5047                    else if (layoutUuid.equals(StringPool.BLANK)) {
5048                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
5049                    }
5050                    else {
5051                            bindLayoutUuid = true;
5052    
5053                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
5054                    }
5055    
5056                    if (orderByComparator != null) {
5057                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5058    
5059                            if (orderByConditionFields.length > 0) {
5060                                    query.append(WHERE_AND);
5061                            }
5062    
5063                            for (int i = 0; i < orderByConditionFields.length; i++) {
5064                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5065                                    query.append(orderByConditionFields[i]);
5066    
5067                                    if ((i + 1) < orderByConditionFields.length) {
5068                                            if (orderByComparator.isAscending() ^ previous) {
5069                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5070                                            }
5071                                            else {
5072                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5073                                            }
5074                                    }
5075                                    else {
5076                                            if (orderByComparator.isAscending() ^ previous) {
5077                                                    query.append(WHERE_GREATER_THAN);
5078                                            }
5079                                            else {
5080                                                    query.append(WHERE_LESSER_THAN);
5081                                            }
5082                                    }
5083                            }
5084    
5085                            query.append(ORDER_BY_CLAUSE);
5086    
5087                            String[] orderByFields = orderByComparator.getOrderByFields();
5088    
5089                            for (int i = 0; i < orderByFields.length; i++) {
5090                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5091                                    query.append(orderByFields[i]);
5092    
5093                                    if ((i + 1) < orderByFields.length) {
5094                                            if (orderByComparator.isAscending() ^ previous) {
5095                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5096                                            }
5097                                            else {
5098                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5099                                            }
5100                                    }
5101                                    else {
5102                                            if (orderByComparator.isAscending() ^ previous) {
5103                                                    query.append(ORDER_BY_ASC);
5104                                            }
5105                                            else {
5106                                                    query.append(ORDER_BY_DESC);
5107                                            }
5108                                    }
5109                            }
5110                    }
5111                    else {
5112                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5113                    }
5114    
5115                    String sql = query.toString();
5116    
5117                    Query q = session.createQuery(sql);
5118    
5119                    q.setFirstResult(0);
5120                    q.setMaxResults(2);
5121    
5122                    QueryPos qPos = QueryPos.getInstance(q);
5123    
5124                    if (bindLayoutUuid) {
5125                            qPos.add(layoutUuid);
5126                    }
5127    
5128                    if (orderByComparator != null) {
5129                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
5130    
5131                            for (Object value : values) {
5132                                    qPos.add(value);
5133                            }
5134                    }
5135    
5136                    List<JournalArticle> list = q.list();
5137    
5138                    if (list.size() == 2) {
5139                            return list.get(1);
5140                    }
5141                    else {
5142                            return null;
5143                    }
5144            }
5145    
5146            /**
5147             * Removes all the journal articles where layoutUuid = &#63; from the database.
5148             *
5149             * @param layoutUuid the layout uuid
5150             * @throws SystemException if a system exception occurred
5151             */
5152            @Override
5153            public void removeByLayoutUuid(String layoutUuid) throws SystemException {
5154                    for (JournalArticle journalArticle : findByLayoutUuid(layoutUuid,
5155                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5156                            remove(journalArticle);
5157                    }
5158            }
5159    
5160            /**
5161             * Returns the number of journal articles where layoutUuid = &#63;.
5162             *
5163             * @param layoutUuid the layout uuid
5164             * @return the number of matching journal articles
5165             * @throws SystemException if a system exception occurred
5166             */
5167            @Override
5168            public int countByLayoutUuid(String layoutUuid) throws SystemException {
5169                    FinderPath finderPath = FINDER_PATH_COUNT_BY_LAYOUTUUID;
5170    
5171                    Object[] finderArgs = new Object[] { layoutUuid };
5172    
5173                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5174                                    this);
5175    
5176                    if (count == null) {
5177                            StringBundler query = new StringBundler(2);
5178    
5179                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
5180    
5181                            boolean bindLayoutUuid = false;
5182    
5183                            if (layoutUuid == null) {
5184                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
5185                            }
5186                            else if (layoutUuid.equals(StringPool.BLANK)) {
5187                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
5188                            }
5189                            else {
5190                                    bindLayoutUuid = true;
5191    
5192                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
5193                            }
5194    
5195                            String sql = query.toString();
5196    
5197                            Session session = null;
5198    
5199                            try {
5200                                    session = openSession();
5201    
5202                                    Query q = session.createQuery(sql);
5203    
5204                                    QueryPos qPos = QueryPos.getInstance(q);
5205    
5206                                    if (bindLayoutUuid) {
5207                                            qPos.add(layoutUuid);
5208                                    }
5209    
5210                                    count = (Long)q.uniqueResult();
5211    
5212                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5213                            }
5214                            catch (Exception e) {
5215                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5216    
5217                                    throw processException(e);
5218                            }
5219                            finally {
5220                                    closeSession(session);
5221                            }
5222                    }
5223    
5224                    return count.intValue();
5225            }
5226    
5227            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
5228            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
5229            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = '')";
5230            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_SMALLIMAGEID =
5231                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5232                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5233                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5234                            "findBySmallImageId",
5235                            new String[] {
5236                                    Long.class.getName(),
5237                                    
5238                            Integer.class.getName(), Integer.class.getName(),
5239                                    OrderByComparator.class.getName()
5240                            });
5241            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID =
5242                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5243                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5244                            JournalArticleImpl.class,
5245                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findBySmallImageId",
5246                            new String[] { Long.class.getName() },
5247                            JournalArticleModelImpl.SMALLIMAGEID_COLUMN_BITMASK |
5248                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
5249                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
5250            public static final FinderPath FINDER_PATH_COUNT_BY_SMALLIMAGEID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5251                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
5252                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countBySmallImageId",
5253                            new String[] { Long.class.getName() });
5254    
5255            /**
5256             * Returns all the journal articles where smallImageId = &#63;.
5257             *
5258             * @param smallImageId the small image ID
5259             * @return the matching journal articles
5260             * @throws SystemException if a system exception occurred
5261             */
5262            @Override
5263            public List<JournalArticle> findBySmallImageId(long smallImageId)
5264                    throws SystemException {
5265                    return findBySmallImageId(smallImageId, QueryUtil.ALL_POS,
5266                            QueryUtil.ALL_POS, null);
5267            }
5268    
5269            /**
5270             * Returns a range of all the journal articles where smallImageId = &#63;.
5271             *
5272             * <p>
5273             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5274             * </p>
5275             *
5276             * @param smallImageId the small image ID
5277             * @param start the lower bound of the range of journal articles
5278             * @param end the upper bound of the range of journal articles (not inclusive)
5279             * @return the range of matching journal articles
5280             * @throws SystemException if a system exception occurred
5281             */
5282            @Override
5283            public List<JournalArticle> findBySmallImageId(long smallImageId,
5284                    int start, int end) throws SystemException {
5285                    return findBySmallImageId(smallImageId, start, end, null);
5286            }
5287    
5288            /**
5289             * Returns an ordered range of all the journal articles where smallImageId = &#63;.
5290             *
5291             * <p>
5292             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5293             * </p>
5294             *
5295             * @param smallImageId the small image ID
5296             * @param start the lower bound of the range of journal articles
5297             * @param end the upper bound of the range of journal articles (not inclusive)
5298             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5299             * @return the ordered range of matching journal articles
5300             * @throws SystemException if a system exception occurred
5301             */
5302            @Override
5303            public List<JournalArticle> findBySmallImageId(long smallImageId,
5304                    int start, int end, OrderByComparator orderByComparator)
5305                    throws SystemException {
5306                    boolean pagination = true;
5307                    FinderPath finderPath = null;
5308                    Object[] finderArgs = null;
5309    
5310                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5311                                    (orderByComparator == null)) {
5312                            pagination = false;
5313                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID;
5314                            finderArgs = new Object[] { smallImageId };
5315                    }
5316                    else {
5317                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_SMALLIMAGEID;
5318                            finderArgs = new Object[] {
5319                                            smallImageId,
5320                                            
5321                                            start, end, orderByComparator
5322                                    };
5323                    }
5324    
5325                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
5326                                    finderArgs, this);
5327    
5328                    if ((list != null) && !list.isEmpty()) {
5329                            for (JournalArticle journalArticle : list) {
5330                                    if ((smallImageId != journalArticle.getSmallImageId())) {
5331                                            list = null;
5332    
5333                                            break;
5334                                    }
5335                            }
5336                    }
5337    
5338                    if (list == null) {
5339                            StringBundler query = null;
5340    
5341                            if (orderByComparator != null) {
5342                                    query = new StringBundler(3 +
5343                                                    (orderByComparator.getOrderByFields().length * 3));
5344                            }
5345                            else {
5346                                    query = new StringBundler(3);
5347                            }
5348    
5349                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5350    
5351                            query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
5352    
5353                            if (orderByComparator != null) {
5354                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5355                                            orderByComparator);
5356                            }
5357                            else
5358                             if (pagination) {
5359                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5360                            }
5361    
5362                            String sql = query.toString();
5363    
5364                            Session session = null;
5365    
5366                            try {
5367                                    session = openSession();
5368    
5369                                    Query q = session.createQuery(sql);
5370    
5371                                    QueryPos qPos = QueryPos.getInstance(q);
5372    
5373                                    qPos.add(smallImageId);
5374    
5375                                    if (!pagination) {
5376                                            list = (List<JournalArticle>)QueryUtil.list(q,
5377                                                            getDialect(), start, end, false);
5378    
5379                                            Collections.sort(list);
5380    
5381                                            list = new UnmodifiableList<JournalArticle>(list);
5382                                    }
5383                                    else {
5384                                            list = (List<JournalArticle>)QueryUtil.list(q,
5385                                                            getDialect(), start, end);
5386                                    }
5387    
5388                                    cacheResult(list);
5389    
5390                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5391                            }
5392                            catch (Exception e) {
5393                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5394    
5395                                    throw processException(e);
5396                            }
5397                            finally {
5398                                    closeSession(session);
5399                            }
5400                    }
5401    
5402                    return list;
5403            }
5404    
5405            /**
5406             * Returns the first journal article in the ordered set where smallImageId = &#63;.
5407             *
5408             * @param smallImageId the small image ID
5409             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5410             * @return the first matching journal article
5411             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5412             * @throws SystemException if a system exception occurred
5413             */
5414            @Override
5415            public JournalArticle findBySmallImageId_First(long smallImageId,
5416                    OrderByComparator orderByComparator)
5417                    throws NoSuchArticleException, SystemException {
5418                    JournalArticle journalArticle = fetchBySmallImageId_First(smallImageId,
5419                                    orderByComparator);
5420    
5421                    if (journalArticle != null) {
5422                            return journalArticle;
5423                    }
5424    
5425                    StringBundler msg = new StringBundler(4);
5426    
5427                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5428    
5429                    msg.append("smallImageId=");
5430                    msg.append(smallImageId);
5431    
5432                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5433    
5434                    throw new NoSuchArticleException(msg.toString());
5435            }
5436    
5437            /**
5438             * Returns the first journal article in the ordered set where smallImageId = &#63;.
5439             *
5440             * @param smallImageId the small image ID
5441             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5442             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
5443             * @throws SystemException if a system exception occurred
5444             */
5445            @Override
5446            public JournalArticle fetchBySmallImageId_First(long smallImageId,
5447                    OrderByComparator orderByComparator) throws SystemException {
5448                    List<JournalArticle> list = findBySmallImageId(smallImageId, 0, 1,
5449                                    orderByComparator);
5450    
5451                    if (!list.isEmpty()) {
5452                            return list.get(0);
5453                    }
5454    
5455                    return null;
5456            }
5457    
5458            /**
5459             * Returns the last journal article in the ordered set where smallImageId = &#63;.
5460             *
5461             * @param smallImageId the small image ID
5462             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5463             * @return the last matching journal article
5464             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5465             * @throws SystemException if a system exception occurred
5466             */
5467            @Override
5468            public JournalArticle findBySmallImageId_Last(long smallImageId,
5469                    OrderByComparator orderByComparator)
5470                    throws NoSuchArticleException, SystemException {
5471                    JournalArticle journalArticle = fetchBySmallImageId_Last(smallImageId,
5472                                    orderByComparator);
5473    
5474                    if (journalArticle != null) {
5475                            return journalArticle;
5476                    }
5477    
5478                    StringBundler msg = new StringBundler(4);
5479    
5480                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5481    
5482                    msg.append("smallImageId=");
5483                    msg.append(smallImageId);
5484    
5485                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5486    
5487                    throw new NoSuchArticleException(msg.toString());
5488            }
5489    
5490            /**
5491             * Returns the last journal article in the ordered set where smallImageId = &#63;.
5492             *
5493             * @param smallImageId the small image ID
5494             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5495             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
5496             * @throws SystemException if a system exception occurred
5497             */
5498            @Override
5499            public JournalArticle fetchBySmallImageId_Last(long smallImageId,
5500                    OrderByComparator orderByComparator) throws SystemException {
5501                    int count = countBySmallImageId(smallImageId);
5502    
5503                    if (count == 0) {
5504                            return null;
5505                    }
5506    
5507                    List<JournalArticle> list = findBySmallImageId(smallImageId, count - 1,
5508                                    count, orderByComparator);
5509    
5510                    if (!list.isEmpty()) {
5511                            return list.get(0);
5512                    }
5513    
5514                    return null;
5515            }
5516    
5517            /**
5518             * Returns the journal articles before and after the current journal article in the ordered set where smallImageId = &#63;.
5519             *
5520             * @param id the primary key of the current journal article
5521             * @param smallImageId the small image ID
5522             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5523             * @return the previous, current, and next journal article
5524             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
5525             * @throws SystemException if a system exception occurred
5526             */
5527            @Override
5528            public JournalArticle[] findBySmallImageId_PrevAndNext(long id,
5529                    long smallImageId, OrderByComparator orderByComparator)
5530                    throws NoSuchArticleException, SystemException {
5531                    JournalArticle journalArticle = findByPrimaryKey(id);
5532    
5533                    Session session = null;
5534    
5535                    try {
5536                            session = openSession();
5537    
5538                            JournalArticle[] array = new JournalArticleImpl[3];
5539    
5540                            array[0] = getBySmallImageId_PrevAndNext(session, journalArticle,
5541                                            smallImageId, orderByComparator, true);
5542    
5543                            array[1] = journalArticle;
5544    
5545                            array[2] = getBySmallImageId_PrevAndNext(session, journalArticle,
5546                                            smallImageId, orderByComparator, false);
5547    
5548                            return array;
5549                    }
5550                    catch (Exception e) {
5551                            throw processException(e);
5552                    }
5553                    finally {
5554                            closeSession(session);
5555                    }
5556            }
5557    
5558            protected JournalArticle getBySmallImageId_PrevAndNext(Session session,
5559                    JournalArticle journalArticle, long smallImageId,
5560                    OrderByComparator orderByComparator, boolean previous) {
5561                    StringBundler query = null;
5562    
5563                    if (orderByComparator != null) {
5564                            query = new StringBundler(6 +
5565                                            (orderByComparator.getOrderByFields().length * 6));
5566                    }
5567                    else {
5568                            query = new StringBundler(3);
5569                    }
5570    
5571                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5572    
5573                    query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
5574    
5575                    if (orderByComparator != null) {
5576                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5577    
5578                            if (orderByConditionFields.length > 0) {
5579                                    query.append(WHERE_AND);
5580                            }
5581    
5582                            for (int i = 0; i < orderByConditionFields.length; i++) {
5583                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5584                                    query.append(orderByConditionFields[i]);
5585    
5586                                    if ((i + 1) < orderByConditionFields.length) {
5587                                            if (orderByComparator.isAscending() ^ previous) {
5588                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5589                                            }
5590                                            else {
5591                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5592                                            }
5593                                    }
5594                                    else {
5595                                            if (orderByComparator.isAscending() ^ previous) {
5596                                                    query.append(WHERE_GREATER_THAN);
5597                                            }
5598                                            else {
5599                                                    query.append(WHERE_LESSER_THAN);
5600                                            }
5601                                    }
5602                            }
5603    
5604                            query.append(ORDER_BY_CLAUSE);
5605    
5606                            String[] orderByFields = orderByComparator.getOrderByFields();
5607    
5608                            for (int i = 0; i < orderByFields.length; i++) {
5609                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5610                                    query.append(orderByFields[i]);
5611    
5612                                    if ((i + 1) < orderByFields.length) {
5613                                            if (orderByComparator.isAscending() ^ previous) {
5614                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5615                                            }
5616                                            else {
5617                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5618                                            }
5619                                    }
5620                                    else {
5621                                            if (orderByComparator.isAscending() ^ previous) {
5622                                                    query.append(ORDER_BY_ASC);
5623                                            }
5624                                            else {
5625                                                    query.append(ORDER_BY_DESC);
5626                                            }
5627                                    }
5628                            }
5629                    }
5630                    else {
5631                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5632                    }
5633    
5634                    String sql = query.toString();
5635    
5636                    Query q = session.createQuery(sql);
5637    
5638                    q.setFirstResult(0);
5639                    q.setMaxResults(2);
5640    
5641                    QueryPos qPos = QueryPos.getInstance(q);
5642    
5643                    qPos.add(smallImageId);
5644    
5645                    if (orderByComparator != null) {
5646                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
5647    
5648                            for (Object value : values) {
5649                                    qPos.add(value);
5650                            }
5651                    }
5652    
5653                    List<JournalArticle> list = q.list();
5654    
5655                    if (list.size() == 2) {
5656                            return list.get(1);
5657                    }
5658                    else {
5659                            return null;
5660                    }
5661            }
5662    
5663            /**
5664             * Removes all the journal articles where smallImageId = &#63; from the database.
5665             *
5666             * @param smallImageId the small image ID
5667             * @throws SystemException if a system exception occurred
5668             */
5669            @Override
5670            public void removeBySmallImageId(long smallImageId)
5671                    throws SystemException {
5672                    for (JournalArticle journalArticle : findBySmallImageId(smallImageId,
5673                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5674                            remove(journalArticle);
5675                    }
5676            }
5677    
5678            /**
5679             * Returns the number of journal articles where smallImageId = &#63;.
5680             *
5681             * @param smallImageId the small image ID
5682             * @return the number of matching journal articles
5683             * @throws SystemException if a system exception occurred
5684             */
5685            @Override
5686            public int countBySmallImageId(long smallImageId) throws SystemException {
5687                    FinderPath finderPath = FINDER_PATH_COUNT_BY_SMALLIMAGEID;
5688    
5689                    Object[] finderArgs = new Object[] { smallImageId };
5690    
5691                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5692                                    this);
5693    
5694                    if (count == null) {
5695                            StringBundler query = new StringBundler(2);
5696    
5697                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
5698    
5699                            query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
5700    
5701                            String sql = query.toString();
5702    
5703                            Session session = null;
5704    
5705                            try {
5706                                    session = openSession();
5707    
5708                                    Query q = session.createQuery(sql);
5709    
5710                                    QueryPos qPos = QueryPos.getInstance(q);
5711    
5712                                    qPos.add(smallImageId);
5713    
5714                                    count = (Long)q.uniqueResult();
5715    
5716                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5717                            }
5718                            catch (Exception e) {
5719                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5720    
5721                                    throw processException(e);
5722                            }
5723                            finally {
5724                                    closeSession(session);
5725                            }
5726                    }
5727    
5728                    return count.intValue();
5729            }
5730    
5731            private static final String _FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2 = "journalArticle.smallImageId = ?";
5732            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5733                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5734                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5735                            "findByR_I",
5736                            new String[] {
5737                                    Long.class.getName(), Boolean.class.getName(),
5738                                    
5739                            Integer.class.getName(), Integer.class.getName(),
5740                                    OrderByComparator.class.getName()
5741                            });
5742            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5743                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5744                            JournalArticleImpl.class,
5745                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_I",
5746                            new String[] { Long.class.getName(), Boolean.class.getName() },
5747                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
5748                            JournalArticleModelImpl.INDEXABLE_COLUMN_BITMASK |
5749                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
5750                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
5751            public static final FinderPath FINDER_PATH_COUNT_BY_R_I = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5752                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
5753                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_I",
5754                            new String[] { Long.class.getName(), Boolean.class.getName() });
5755    
5756            /**
5757             * Returns all the journal articles where resourcePrimKey = &#63; and indexable = &#63;.
5758             *
5759             * @param resourcePrimKey the resource prim key
5760             * @param indexable the indexable
5761             * @return the matching journal articles
5762             * @throws SystemException if a system exception occurred
5763             */
5764            @Override
5765            public List<JournalArticle> findByR_I(long resourcePrimKey,
5766                    boolean indexable) throws SystemException {
5767                    return findByR_I(resourcePrimKey, indexable, QueryUtil.ALL_POS,
5768                            QueryUtil.ALL_POS, null);
5769            }
5770    
5771            /**
5772             * Returns a range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63;.
5773             *
5774             * <p>
5775             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5776             * </p>
5777             *
5778             * @param resourcePrimKey the resource prim key
5779             * @param indexable the indexable
5780             * @param start the lower bound of the range of journal articles
5781             * @param end the upper bound of the range of journal articles (not inclusive)
5782             * @return the range of matching journal articles
5783             * @throws SystemException if a system exception occurred
5784             */
5785            @Override
5786            public List<JournalArticle> findByR_I(long resourcePrimKey,
5787                    boolean indexable, int start, int end) throws SystemException {
5788                    return findByR_I(resourcePrimKey, indexable, start, end, null);
5789            }
5790    
5791            /**
5792             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63;.
5793             *
5794             * <p>
5795             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5796             * </p>
5797             *
5798             * @param resourcePrimKey the resource prim key
5799             * @param indexable the indexable
5800             * @param start the lower bound of the range of journal articles
5801             * @param end the upper bound of the range of journal articles (not inclusive)
5802             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5803             * @return the ordered range of matching journal articles
5804             * @throws SystemException if a system exception occurred
5805             */
5806            @Override
5807            public List<JournalArticle> findByR_I(long resourcePrimKey,
5808                    boolean indexable, int start, int end,
5809                    OrderByComparator orderByComparator) throws SystemException {
5810                    boolean pagination = true;
5811                    FinderPath finderPath = null;
5812                    Object[] finderArgs = null;
5813    
5814                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5815                                    (orderByComparator == null)) {
5816                            pagination = false;
5817                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I;
5818                            finderArgs = new Object[] { resourcePrimKey, indexable };
5819                    }
5820                    else {
5821                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I;
5822                            finderArgs = new Object[] {
5823                                            resourcePrimKey, indexable,
5824                                            
5825                                            start, end, orderByComparator
5826                                    };
5827                    }
5828    
5829                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
5830                                    finderArgs, this);
5831    
5832                    if ((list != null) && !list.isEmpty()) {
5833                            for (JournalArticle journalArticle : list) {
5834                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
5835                                                    (indexable != journalArticle.getIndexable())) {
5836                                            list = null;
5837    
5838                                            break;
5839                                    }
5840                            }
5841                    }
5842    
5843                    if (list == null) {
5844                            StringBundler query = null;
5845    
5846                            if (orderByComparator != null) {
5847                                    query = new StringBundler(4 +
5848                                                    (orderByComparator.getOrderByFields().length * 3));
5849                            }
5850                            else {
5851                                    query = new StringBundler(4);
5852                            }
5853    
5854                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5855    
5856                            query.append(_FINDER_COLUMN_R_I_RESOURCEPRIMKEY_2);
5857    
5858                            query.append(_FINDER_COLUMN_R_I_INDEXABLE_2);
5859    
5860                            if (orderByComparator != null) {
5861                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5862                                            orderByComparator);
5863                            }
5864                            else
5865                             if (pagination) {
5866                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5867                            }
5868    
5869                            String sql = query.toString();
5870    
5871                            Session session = null;
5872    
5873                            try {
5874                                    session = openSession();
5875    
5876                                    Query q = session.createQuery(sql);
5877    
5878                                    QueryPos qPos = QueryPos.getInstance(q);
5879    
5880                                    qPos.add(resourcePrimKey);
5881    
5882                                    qPos.add(indexable);
5883    
5884                                    if (!pagination) {
5885                                            list = (List<JournalArticle>)QueryUtil.list(q,
5886                                                            getDialect(), start, end, false);
5887    
5888                                            Collections.sort(list);
5889    
5890                                            list = new UnmodifiableList<JournalArticle>(list);
5891                                    }
5892                                    else {
5893                                            list = (List<JournalArticle>)QueryUtil.list(q,
5894                                                            getDialect(), start, end);
5895                                    }
5896    
5897                                    cacheResult(list);
5898    
5899                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5900                            }
5901                            catch (Exception e) {
5902                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5903    
5904                                    throw processException(e);
5905                            }
5906                            finally {
5907                                    closeSession(session);
5908                            }
5909                    }
5910    
5911                    return list;
5912            }
5913    
5914            /**
5915             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63;.
5916             *
5917             * @param resourcePrimKey the resource prim key
5918             * @param indexable the indexable
5919             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5920             * @return the first matching journal article
5921             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5922             * @throws SystemException if a system exception occurred
5923             */
5924            @Override
5925            public JournalArticle findByR_I_First(long resourcePrimKey,
5926                    boolean indexable, OrderByComparator orderByComparator)
5927                    throws NoSuchArticleException, SystemException {
5928                    JournalArticle journalArticle = fetchByR_I_First(resourcePrimKey,
5929                                    indexable, orderByComparator);
5930    
5931                    if (journalArticle != null) {
5932                            return journalArticle;
5933                    }
5934    
5935                    StringBundler msg = new StringBundler(6);
5936    
5937                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5938    
5939                    msg.append("resourcePrimKey=");
5940                    msg.append(resourcePrimKey);
5941    
5942                    msg.append(", indexable=");
5943                    msg.append(indexable);
5944    
5945                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5946    
5947                    throw new NoSuchArticleException(msg.toString());
5948            }
5949    
5950            /**
5951             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63;.
5952             *
5953             * @param resourcePrimKey the resource prim key
5954             * @param indexable the indexable
5955             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5956             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
5957             * @throws SystemException if a system exception occurred
5958             */
5959            @Override
5960            public JournalArticle fetchByR_I_First(long resourcePrimKey,
5961                    boolean indexable, OrderByComparator orderByComparator)
5962                    throws SystemException {
5963                    List<JournalArticle> list = findByR_I(resourcePrimKey, indexable, 0, 1,
5964                                    orderByComparator);
5965    
5966                    if (!list.isEmpty()) {
5967                            return list.get(0);
5968                    }
5969    
5970                    return null;
5971            }
5972    
5973            /**
5974             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63;.
5975             *
5976             * @param resourcePrimKey the resource prim key
5977             * @param indexable the indexable
5978             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5979             * @return the last matching journal article
5980             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5981             * @throws SystemException if a system exception occurred
5982             */
5983            @Override
5984            public JournalArticle findByR_I_Last(long resourcePrimKey,
5985                    boolean indexable, OrderByComparator orderByComparator)
5986                    throws NoSuchArticleException, SystemException {
5987                    JournalArticle journalArticle = fetchByR_I_Last(resourcePrimKey,
5988                                    indexable, orderByComparator);
5989    
5990                    if (journalArticle != null) {
5991                            return journalArticle;
5992                    }
5993    
5994                    StringBundler msg = new StringBundler(6);
5995    
5996                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5997    
5998                    msg.append("resourcePrimKey=");
5999                    msg.append(resourcePrimKey);
6000    
6001                    msg.append(", indexable=");
6002                    msg.append(indexable);
6003    
6004                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6005    
6006                    throw new NoSuchArticleException(msg.toString());
6007            }
6008    
6009            /**
6010             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63;.
6011             *
6012             * @param resourcePrimKey the resource prim key
6013             * @param indexable the indexable
6014             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6015             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
6016             * @throws SystemException if a system exception occurred
6017             */
6018            @Override
6019            public JournalArticle fetchByR_I_Last(long resourcePrimKey,
6020                    boolean indexable, OrderByComparator orderByComparator)
6021                    throws SystemException {
6022                    int count = countByR_I(resourcePrimKey, indexable);
6023    
6024                    if (count == 0) {
6025                            return null;
6026                    }
6027    
6028                    List<JournalArticle> list = findByR_I(resourcePrimKey, indexable,
6029                                    count - 1, count, orderByComparator);
6030    
6031                    if (!list.isEmpty()) {
6032                            return list.get(0);
6033                    }
6034    
6035                    return null;
6036            }
6037    
6038            /**
6039             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63;.
6040             *
6041             * @param id the primary key of the current journal article
6042             * @param resourcePrimKey the resource prim key
6043             * @param indexable the indexable
6044             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6045             * @return the previous, current, and next journal article
6046             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6047             * @throws SystemException if a system exception occurred
6048             */
6049            @Override
6050            public JournalArticle[] findByR_I_PrevAndNext(long id,
6051                    long resourcePrimKey, boolean indexable,
6052                    OrderByComparator orderByComparator)
6053                    throws NoSuchArticleException, SystemException {
6054                    JournalArticle journalArticle = findByPrimaryKey(id);
6055    
6056                    Session session = null;
6057    
6058                    try {
6059                            session = openSession();
6060    
6061                            JournalArticle[] array = new JournalArticleImpl[3];
6062    
6063                            array[0] = getByR_I_PrevAndNext(session, journalArticle,
6064                                            resourcePrimKey, indexable, orderByComparator, true);
6065    
6066                            array[1] = journalArticle;
6067    
6068                            array[2] = getByR_I_PrevAndNext(session, journalArticle,
6069                                            resourcePrimKey, indexable, orderByComparator, false);
6070    
6071                            return array;
6072                    }
6073                    catch (Exception e) {
6074                            throw processException(e);
6075                    }
6076                    finally {
6077                            closeSession(session);
6078                    }
6079            }
6080    
6081            protected JournalArticle getByR_I_PrevAndNext(Session session,
6082                    JournalArticle journalArticle, long resourcePrimKey, boolean indexable,
6083                    OrderByComparator orderByComparator, boolean previous) {
6084                    StringBundler query = null;
6085    
6086                    if (orderByComparator != null) {
6087                            query = new StringBundler(6 +
6088                                            (orderByComparator.getOrderByFields().length * 6));
6089                    }
6090                    else {
6091                            query = new StringBundler(3);
6092                    }
6093    
6094                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6095    
6096                    query.append(_FINDER_COLUMN_R_I_RESOURCEPRIMKEY_2);
6097    
6098                    query.append(_FINDER_COLUMN_R_I_INDEXABLE_2);
6099    
6100                    if (orderByComparator != null) {
6101                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6102    
6103                            if (orderByConditionFields.length > 0) {
6104                                    query.append(WHERE_AND);
6105                            }
6106    
6107                            for (int i = 0; i < orderByConditionFields.length; i++) {
6108                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6109                                    query.append(orderByConditionFields[i]);
6110    
6111                                    if ((i + 1) < orderByConditionFields.length) {
6112                                            if (orderByComparator.isAscending() ^ previous) {
6113                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6114                                            }
6115                                            else {
6116                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6117                                            }
6118                                    }
6119                                    else {
6120                                            if (orderByComparator.isAscending() ^ previous) {
6121                                                    query.append(WHERE_GREATER_THAN);
6122                                            }
6123                                            else {
6124                                                    query.append(WHERE_LESSER_THAN);
6125                                            }
6126                                    }
6127                            }
6128    
6129                            query.append(ORDER_BY_CLAUSE);
6130    
6131                            String[] orderByFields = orderByComparator.getOrderByFields();
6132    
6133                            for (int i = 0; i < orderByFields.length; i++) {
6134                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6135                                    query.append(orderByFields[i]);
6136    
6137                                    if ((i + 1) < orderByFields.length) {
6138                                            if (orderByComparator.isAscending() ^ previous) {
6139                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6140                                            }
6141                                            else {
6142                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6143                                            }
6144                                    }
6145                                    else {
6146                                            if (orderByComparator.isAscending() ^ previous) {
6147                                                    query.append(ORDER_BY_ASC);
6148                                            }
6149                                            else {
6150                                                    query.append(ORDER_BY_DESC);
6151                                            }
6152                                    }
6153                            }
6154                    }
6155                    else {
6156                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6157                    }
6158    
6159                    String sql = query.toString();
6160    
6161                    Query q = session.createQuery(sql);
6162    
6163                    q.setFirstResult(0);
6164                    q.setMaxResults(2);
6165    
6166                    QueryPos qPos = QueryPos.getInstance(q);
6167    
6168                    qPos.add(resourcePrimKey);
6169    
6170                    qPos.add(indexable);
6171    
6172                    if (orderByComparator != null) {
6173                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6174    
6175                            for (Object value : values) {
6176                                    qPos.add(value);
6177                            }
6178                    }
6179    
6180                    List<JournalArticle> list = q.list();
6181    
6182                    if (list.size() == 2) {
6183                            return list.get(1);
6184                    }
6185                    else {
6186                            return null;
6187                    }
6188            }
6189    
6190            /**
6191             * Removes all the journal articles where resourcePrimKey = &#63; and indexable = &#63; from the database.
6192             *
6193             * @param resourcePrimKey the resource prim key
6194             * @param indexable the indexable
6195             * @throws SystemException if a system exception occurred
6196             */
6197            @Override
6198            public void removeByR_I(long resourcePrimKey, boolean indexable)
6199                    throws SystemException {
6200                    for (JournalArticle journalArticle : findByR_I(resourcePrimKey,
6201                                    indexable, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6202                            remove(journalArticle);
6203                    }
6204            }
6205    
6206            /**
6207             * Returns the number of journal articles where resourcePrimKey = &#63; and indexable = &#63;.
6208             *
6209             * @param resourcePrimKey the resource prim key
6210             * @param indexable the indexable
6211             * @return the number of matching journal articles
6212             * @throws SystemException if a system exception occurred
6213             */
6214            @Override
6215            public int countByR_I(long resourcePrimKey, boolean indexable)
6216                    throws SystemException {
6217                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_I;
6218    
6219                    Object[] finderArgs = new Object[] { resourcePrimKey, indexable };
6220    
6221                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6222                                    this);
6223    
6224                    if (count == null) {
6225                            StringBundler query = new StringBundler(3);
6226    
6227                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
6228    
6229                            query.append(_FINDER_COLUMN_R_I_RESOURCEPRIMKEY_2);
6230    
6231                            query.append(_FINDER_COLUMN_R_I_INDEXABLE_2);
6232    
6233                            String sql = query.toString();
6234    
6235                            Session session = null;
6236    
6237                            try {
6238                                    session = openSession();
6239    
6240                                    Query q = session.createQuery(sql);
6241    
6242                                    QueryPos qPos = QueryPos.getInstance(q);
6243    
6244                                    qPos.add(resourcePrimKey);
6245    
6246                                    qPos.add(indexable);
6247    
6248                                    count = (Long)q.uniqueResult();
6249    
6250                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6251                            }
6252                            catch (Exception e) {
6253                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6254    
6255                                    throw processException(e);
6256                            }
6257                            finally {
6258                                    closeSession(session);
6259                            }
6260                    }
6261    
6262                    return count.intValue();
6263            }
6264    
6265            private static final String _FINDER_COLUMN_R_I_RESOURCEPRIMKEY_2 = "journalArticle.resourcePrimKey = ? AND ";
6266            private static final String _FINDER_COLUMN_R_I_INDEXABLE_2 = "journalArticle.indexable = ?";
6267            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6268                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
6269                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
6270                            "findByR_ST",
6271                            new String[] {
6272                                    Long.class.getName(), Integer.class.getName(),
6273                                    
6274                            Integer.class.getName(), Integer.class.getName(),
6275                                    OrderByComparator.class.getName()
6276                            });
6277            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6278                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
6279                            JournalArticleImpl.class,
6280                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_ST",
6281                            new String[] { Long.class.getName(), Integer.class.getName() },
6282                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
6283                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
6284                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
6285                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
6286            public static final FinderPath FINDER_PATH_COUNT_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6287                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
6288                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_ST",
6289                            new String[] { Long.class.getName(), Integer.class.getName() });
6290            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6291                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
6292                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByR_ST",
6293                            new String[] { Long.class.getName(), Integer.class.getName() });
6294    
6295            /**
6296             * Returns all the journal articles where resourcePrimKey = &#63; and status = &#63;.
6297             *
6298             * @param resourcePrimKey the resource prim key
6299             * @param status the status
6300             * @return the matching journal articles
6301             * @throws SystemException if a system exception occurred
6302             */
6303            @Override
6304            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status)
6305                    throws SystemException {
6306                    return findByR_ST(resourcePrimKey, status, QueryUtil.ALL_POS,
6307                            QueryUtil.ALL_POS, null);
6308            }
6309    
6310            /**
6311             * Returns a range of all the journal articles where resourcePrimKey = &#63; and status = &#63;.
6312             *
6313             * <p>
6314             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6315             * </p>
6316             *
6317             * @param resourcePrimKey the resource prim key
6318             * @param status the status
6319             * @param start the lower bound of the range of journal articles
6320             * @param end the upper bound of the range of journal articles (not inclusive)
6321             * @return the range of matching journal articles
6322             * @throws SystemException if a system exception occurred
6323             */
6324            @Override
6325            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status,
6326                    int start, int end) throws SystemException {
6327                    return findByR_ST(resourcePrimKey, status, start, end, null);
6328            }
6329    
6330            /**
6331             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and status = &#63;.
6332             *
6333             * <p>
6334             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6335             * </p>
6336             *
6337             * @param resourcePrimKey the resource prim key
6338             * @param status the status
6339             * @param start the lower bound of the range of journal articles
6340             * @param end the upper bound of the range of journal articles (not inclusive)
6341             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6342             * @return the ordered range of matching journal articles
6343             * @throws SystemException if a system exception occurred
6344             */
6345            @Override
6346            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status,
6347                    int start, int end, OrderByComparator orderByComparator)
6348                    throws SystemException {
6349                    boolean pagination = true;
6350                    FinderPath finderPath = null;
6351                    Object[] finderArgs = null;
6352    
6353                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6354                                    (orderByComparator == null)) {
6355                            pagination = false;
6356                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST;
6357                            finderArgs = new Object[] { resourcePrimKey, status };
6358                    }
6359                    else {
6360                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST;
6361                            finderArgs = new Object[] {
6362                                            resourcePrimKey, status,
6363                                            
6364                                            start, end, orderByComparator
6365                                    };
6366                    }
6367    
6368                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
6369                                    finderArgs, this);
6370    
6371                    if ((list != null) && !list.isEmpty()) {
6372                            for (JournalArticle journalArticle : list) {
6373                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
6374                                                    (status != journalArticle.getStatus())) {
6375                                            list = null;
6376    
6377                                            break;
6378                                    }
6379                            }
6380                    }
6381    
6382                    if (list == null) {
6383                            StringBundler query = null;
6384    
6385                            if (orderByComparator != null) {
6386                                    query = new StringBundler(4 +
6387                                                    (orderByComparator.getOrderByFields().length * 3));
6388                            }
6389                            else {
6390                                    query = new StringBundler(4);
6391                            }
6392    
6393                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6394    
6395                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
6396    
6397                            query.append(_FINDER_COLUMN_R_ST_STATUS_2);
6398    
6399                            if (orderByComparator != null) {
6400                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6401                                            orderByComparator);
6402                            }
6403                            else
6404                             if (pagination) {
6405                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6406                            }
6407    
6408                            String sql = query.toString();
6409    
6410                            Session session = null;
6411    
6412                            try {
6413                                    session = openSession();
6414    
6415                                    Query q = session.createQuery(sql);
6416    
6417                                    QueryPos qPos = QueryPos.getInstance(q);
6418    
6419                                    qPos.add(resourcePrimKey);
6420    
6421                                    qPos.add(status);
6422    
6423                                    if (!pagination) {
6424                                            list = (List<JournalArticle>)QueryUtil.list(q,
6425                                                            getDialect(), start, end, false);
6426    
6427                                            Collections.sort(list);
6428    
6429                                            list = new UnmodifiableList<JournalArticle>(list);
6430                                    }
6431                                    else {
6432                                            list = (List<JournalArticle>)QueryUtil.list(q,
6433                                                            getDialect(), start, end);
6434                                    }
6435    
6436                                    cacheResult(list);
6437    
6438                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6439                            }
6440                            catch (Exception e) {
6441                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6442    
6443                                    throw processException(e);
6444                            }
6445                            finally {
6446                                    closeSession(session);
6447                            }
6448                    }
6449    
6450                    return list;
6451            }
6452    
6453            /**
6454             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6455             *
6456             * @param resourcePrimKey the resource prim key
6457             * @param status the status
6458             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6459             * @return the first matching journal article
6460             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6461             * @throws SystemException if a system exception occurred
6462             */
6463            @Override
6464            public JournalArticle findByR_ST_First(long resourcePrimKey, int status,
6465                    OrderByComparator orderByComparator)
6466                    throws NoSuchArticleException, SystemException {
6467                    JournalArticle journalArticle = fetchByR_ST_First(resourcePrimKey,
6468                                    status, orderByComparator);
6469    
6470                    if (journalArticle != null) {
6471                            return journalArticle;
6472                    }
6473    
6474                    StringBundler msg = new StringBundler(6);
6475    
6476                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6477    
6478                    msg.append("resourcePrimKey=");
6479                    msg.append(resourcePrimKey);
6480    
6481                    msg.append(", status=");
6482                    msg.append(status);
6483    
6484                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6485    
6486                    throw new NoSuchArticleException(msg.toString());
6487            }
6488    
6489            /**
6490             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6491             *
6492             * @param resourcePrimKey the resource prim key
6493             * @param status the status
6494             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6495             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
6496             * @throws SystemException if a system exception occurred
6497             */
6498            @Override
6499            public JournalArticle fetchByR_ST_First(long resourcePrimKey, int status,
6500                    OrderByComparator orderByComparator) throws SystemException {
6501                    List<JournalArticle> list = findByR_ST(resourcePrimKey, status, 0, 1,
6502                                    orderByComparator);
6503    
6504                    if (!list.isEmpty()) {
6505                            return list.get(0);
6506                    }
6507    
6508                    return null;
6509            }
6510    
6511            /**
6512             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6513             *
6514             * @param resourcePrimKey the resource prim key
6515             * @param status the status
6516             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6517             * @return the last matching journal article
6518             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6519             * @throws SystemException if a system exception occurred
6520             */
6521            @Override
6522            public JournalArticle findByR_ST_Last(long resourcePrimKey, int status,
6523                    OrderByComparator orderByComparator)
6524                    throws NoSuchArticleException, SystemException {
6525                    JournalArticle journalArticle = fetchByR_ST_Last(resourcePrimKey,
6526                                    status, orderByComparator);
6527    
6528                    if (journalArticle != null) {
6529                            return journalArticle;
6530                    }
6531    
6532                    StringBundler msg = new StringBundler(6);
6533    
6534                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6535    
6536                    msg.append("resourcePrimKey=");
6537                    msg.append(resourcePrimKey);
6538    
6539                    msg.append(", status=");
6540                    msg.append(status);
6541    
6542                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6543    
6544                    throw new NoSuchArticleException(msg.toString());
6545            }
6546    
6547            /**
6548             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6549             *
6550             * @param resourcePrimKey the resource prim key
6551             * @param status the status
6552             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6553             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
6554             * @throws SystemException if a system exception occurred
6555             */
6556            @Override
6557            public JournalArticle fetchByR_ST_Last(long resourcePrimKey, int status,
6558                    OrderByComparator orderByComparator) throws SystemException {
6559                    int count = countByR_ST(resourcePrimKey, status);
6560    
6561                    if (count == 0) {
6562                            return null;
6563                    }
6564    
6565                    List<JournalArticle> list = findByR_ST(resourcePrimKey, status,
6566                                    count - 1, count, orderByComparator);
6567    
6568                    if (!list.isEmpty()) {
6569                            return list.get(0);
6570                    }
6571    
6572                    return null;
6573            }
6574    
6575            /**
6576             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6577             *
6578             * @param id the primary key of the current journal article
6579             * @param resourcePrimKey the resource prim key
6580             * @param status the status
6581             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6582             * @return the previous, current, and next journal article
6583             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6584             * @throws SystemException if a system exception occurred
6585             */
6586            @Override
6587            public JournalArticle[] findByR_ST_PrevAndNext(long id,
6588                    long resourcePrimKey, int status, OrderByComparator orderByComparator)
6589                    throws NoSuchArticleException, SystemException {
6590                    JournalArticle journalArticle = findByPrimaryKey(id);
6591    
6592                    Session session = null;
6593    
6594                    try {
6595                            session = openSession();
6596    
6597                            JournalArticle[] array = new JournalArticleImpl[3];
6598    
6599                            array[0] = getByR_ST_PrevAndNext(session, journalArticle,
6600                                            resourcePrimKey, status, orderByComparator, true);
6601    
6602                            array[1] = journalArticle;
6603    
6604                            array[2] = getByR_ST_PrevAndNext(session, journalArticle,
6605                                            resourcePrimKey, status, orderByComparator, false);
6606    
6607                            return array;
6608                    }
6609                    catch (Exception e) {
6610                            throw processException(e);
6611                    }
6612                    finally {
6613                            closeSession(session);
6614                    }
6615            }
6616    
6617            protected JournalArticle getByR_ST_PrevAndNext(Session session,
6618                    JournalArticle journalArticle, long resourcePrimKey, int status,
6619                    OrderByComparator orderByComparator, boolean previous) {
6620                    StringBundler query = null;
6621    
6622                    if (orderByComparator != null) {
6623                            query = new StringBundler(6 +
6624                                            (orderByComparator.getOrderByFields().length * 6));
6625                    }
6626                    else {
6627                            query = new StringBundler(3);
6628                    }
6629    
6630                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6631    
6632                    query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
6633    
6634                    query.append(_FINDER_COLUMN_R_ST_STATUS_2);
6635    
6636                    if (orderByComparator != null) {
6637                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6638    
6639                            if (orderByConditionFields.length > 0) {
6640                                    query.append(WHERE_AND);
6641                            }
6642    
6643                            for (int i = 0; i < orderByConditionFields.length; i++) {
6644                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6645                                    query.append(orderByConditionFields[i]);
6646    
6647                                    if ((i + 1) < orderByConditionFields.length) {
6648                                            if (orderByComparator.isAscending() ^ previous) {
6649                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6650                                            }
6651                                            else {
6652                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6653                                            }
6654                                    }
6655                                    else {
6656                                            if (orderByComparator.isAscending() ^ previous) {
6657                                                    query.append(WHERE_GREATER_THAN);
6658                                            }
6659                                            else {
6660                                                    query.append(WHERE_LESSER_THAN);
6661                                            }
6662                                    }
6663                            }
6664    
6665                            query.append(ORDER_BY_CLAUSE);
6666    
6667                            String[] orderByFields = orderByComparator.getOrderByFields();
6668    
6669                            for (int i = 0; i < orderByFields.length; i++) {
6670                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6671                                    query.append(orderByFields[i]);
6672    
6673                                    if ((i + 1) < orderByFields.length) {
6674                                            if (orderByComparator.isAscending() ^ previous) {
6675                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6676                                            }
6677                                            else {
6678                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6679                                            }
6680                                    }
6681                                    else {
6682                                            if (orderByComparator.isAscending() ^ previous) {
6683                                                    query.append(ORDER_BY_ASC);
6684                                            }
6685                                            else {
6686                                                    query.append(ORDER_BY_DESC);
6687                                            }
6688                                    }
6689                            }
6690                    }
6691                    else {
6692                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6693                    }
6694    
6695                    String sql = query.toString();
6696    
6697                    Query q = session.createQuery(sql);
6698    
6699                    q.setFirstResult(0);
6700                    q.setMaxResults(2);
6701    
6702                    QueryPos qPos = QueryPos.getInstance(q);
6703    
6704                    qPos.add(resourcePrimKey);
6705    
6706                    qPos.add(status);
6707    
6708                    if (orderByComparator != null) {
6709                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6710    
6711                            for (Object value : values) {
6712                                    qPos.add(value);
6713                            }
6714                    }
6715    
6716                    List<JournalArticle> list = q.list();
6717    
6718                    if (list.size() == 2) {
6719                            return list.get(1);
6720                    }
6721                    else {
6722                            return null;
6723                    }
6724            }
6725    
6726            /**
6727             * Returns all the journal articles where resourcePrimKey = &#63; and status = any &#63;.
6728             *
6729             * <p>
6730             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6731             * </p>
6732             *
6733             * @param resourcePrimKey the resource prim key
6734             * @param statuses the statuses
6735             * @return the matching journal articles
6736             * @throws SystemException if a system exception occurred
6737             */
6738            @Override
6739            public List<JournalArticle> findByR_ST(long resourcePrimKey, int[] statuses)
6740                    throws SystemException {
6741                    return findByR_ST(resourcePrimKey, statuses, QueryUtil.ALL_POS,
6742                            QueryUtil.ALL_POS, null);
6743            }
6744    
6745            /**
6746             * Returns a range of all the journal articles where resourcePrimKey = &#63; and status = any &#63;.
6747             *
6748             * <p>
6749             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6750             * </p>
6751             *
6752             * @param resourcePrimKey the resource prim key
6753             * @param statuses the statuses
6754             * @param start the lower bound of the range of journal articles
6755             * @param end the upper bound of the range of journal articles (not inclusive)
6756             * @return the range of matching journal articles
6757             * @throws SystemException if a system exception occurred
6758             */
6759            @Override
6760            public List<JournalArticle> findByR_ST(long resourcePrimKey,
6761                    int[] statuses, int start, int end) throws SystemException {
6762                    return findByR_ST(resourcePrimKey, statuses, start, end, null);
6763            }
6764    
6765            /**
6766             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and status = any &#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 resourcePrimKey the resource prim key
6773             * @param statuses the statuses
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             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6777             * @return the ordered range of matching journal articles
6778             * @throws SystemException if a system exception occurred
6779             */
6780            @Override
6781            public List<JournalArticle> findByR_ST(long resourcePrimKey,
6782                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
6783                    throws SystemException {
6784                    if ((statuses != null) && (statuses.length == 1)) {
6785                            return findByR_ST(resourcePrimKey, statuses[0], start, end,
6786                                    orderByComparator);
6787                    }
6788    
6789                    boolean pagination = true;
6790                    Object[] finderArgs = null;
6791    
6792                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6793                                    (orderByComparator == null)) {
6794                            pagination = false;
6795                            finderArgs = new Object[] {
6796                                            resourcePrimKey, StringUtil.merge(statuses)
6797                                    };
6798                    }
6799                    else {
6800                            finderArgs = new Object[] {
6801                                            resourcePrimKey, StringUtil.merge(statuses),
6802                                            
6803                                            start, end, orderByComparator
6804                                    };
6805                    }
6806    
6807                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST,
6808                                    finderArgs, this);
6809    
6810                    if ((list != null) && !list.isEmpty()) {
6811                            for (JournalArticle journalArticle : list) {
6812                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
6813                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
6814                                            list = null;
6815    
6816                                            break;
6817                                    }
6818                            }
6819                    }
6820    
6821                    if (list == null) {
6822                            StringBundler query = new StringBundler();
6823    
6824                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6825    
6826                            boolean conjunctionable = false;
6827    
6828                            if (conjunctionable) {
6829                                    query.append(WHERE_AND);
6830                            }
6831    
6832                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_5);
6833    
6834                            conjunctionable = true;
6835    
6836                            if ((statuses == null) || (statuses.length > 0)) {
6837                                    if (conjunctionable) {
6838                                            query.append(WHERE_AND);
6839                                    }
6840    
6841                                    query.append(StringPool.OPEN_PARENTHESIS);
6842    
6843                                    for (int i = 0; i < statuses.length; i++) {
6844                                            query.append(_FINDER_COLUMN_R_ST_STATUS_5);
6845    
6846                                            if ((i + 1) < statuses.length) {
6847                                                    query.append(WHERE_OR);
6848                                            }
6849                                    }
6850    
6851                                    query.append(StringPool.CLOSE_PARENTHESIS);
6852    
6853                                    conjunctionable = true;
6854                            }
6855    
6856                            if (orderByComparator != null) {
6857                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6858                                            orderByComparator);
6859                            }
6860                            else
6861                             if (pagination) {
6862                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6863                            }
6864    
6865                            String sql = query.toString();
6866    
6867                            Session session = null;
6868    
6869                            try {
6870                                    session = openSession();
6871    
6872                                    Query q = session.createQuery(sql);
6873    
6874                                    QueryPos qPos = QueryPos.getInstance(q);
6875    
6876                                    qPos.add(resourcePrimKey);
6877    
6878                                    if (statuses != null) {
6879                                            qPos.add(statuses);
6880                                    }
6881    
6882                                    if (!pagination) {
6883                                            list = (List<JournalArticle>)QueryUtil.list(q,
6884                                                            getDialect(), start, end, false);
6885    
6886                                            Collections.sort(list);
6887    
6888                                            list = new UnmodifiableList<JournalArticle>(list);
6889                                    }
6890                                    else {
6891                                            list = (List<JournalArticle>)QueryUtil.list(q,
6892                                                            getDialect(), start, end);
6893                                    }
6894    
6895                                    cacheResult(list);
6896    
6897                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST,
6898                                            finderArgs, list);
6899                            }
6900                            catch (Exception e) {
6901                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST,
6902                                            finderArgs);
6903    
6904                                    throw processException(e);
6905                            }
6906                            finally {
6907                                    closeSession(session);
6908                            }
6909                    }
6910    
6911                    return list;
6912            }
6913    
6914            /**
6915             * Removes all the journal articles where resourcePrimKey = &#63; and status = &#63; from the database.
6916             *
6917             * @param resourcePrimKey the resource prim key
6918             * @param status the status
6919             * @throws SystemException if a system exception occurred
6920             */
6921            @Override
6922            public void removeByR_ST(long resourcePrimKey, int status)
6923                    throws SystemException {
6924                    for (JournalArticle journalArticle : findByR_ST(resourcePrimKey,
6925                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6926                            remove(journalArticle);
6927                    }
6928            }
6929    
6930            /**
6931             * Returns the number of journal articles where resourcePrimKey = &#63; and status = &#63;.
6932             *
6933             * @param resourcePrimKey the resource prim key
6934             * @param status the status
6935             * @return the number of matching journal articles
6936             * @throws SystemException if a system exception occurred
6937             */
6938            @Override
6939            public int countByR_ST(long resourcePrimKey, int status)
6940                    throws SystemException {
6941                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_ST;
6942    
6943                    Object[] finderArgs = new Object[] { resourcePrimKey, status };
6944    
6945                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6946                                    this);
6947    
6948                    if (count == null) {
6949                            StringBundler query = new StringBundler(3);
6950    
6951                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
6952    
6953                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
6954    
6955                            query.append(_FINDER_COLUMN_R_ST_STATUS_2);
6956    
6957                            String sql = query.toString();
6958    
6959                            Session session = null;
6960    
6961                            try {
6962                                    session = openSession();
6963    
6964                                    Query q = session.createQuery(sql);
6965    
6966                                    QueryPos qPos = QueryPos.getInstance(q);
6967    
6968                                    qPos.add(resourcePrimKey);
6969    
6970                                    qPos.add(status);
6971    
6972                                    count = (Long)q.uniqueResult();
6973    
6974                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6975                            }
6976                            catch (Exception e) {
6977                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6978    
6979                                    throw processException(e);
6980                            }
6981                            finally {
6982                                    closeSession(session);
6983                            }
6984                    }
6985    
6986                    return count.intValue();
6987            }
6988    
6989            /**
6990             * Returns the number of journal articles where resourcePrimKey = &#63; and status = any &#63;.
6991             *
6992             * @param resourcePrimKey the resource prim key
6993             * @param statuses the statuses
6994             * @return the number of matching journal articles
6995             * @throws SystemException if a system exception occurred
6996             */
6997            @Override
6998            public int countByR_ST(long resourcePrimKey, int[] statuses)
6999                    throws SystemException {
7000                    Object[] finderArgs = new Object[] {
7001                                    resourcePrimKey, StringUtil.merge(statuses)
7002                            };
7003    
7004                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_ST,
7005                                    finderArgs, this);
7006    
7007                    if (count == null) {
7008                            StringBundler query = new StringBundler();
7009    
7010                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
7011    
7012                            boolean conjunctionable = false;
7013    
7014                            if (conjunctionable) {
7015                                    query.append(WHERE_AND);
7016                            }
7017    
7018                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_5);
7019    
7020                            conjunctionable = true;
7021    
7022                            if ((statuses == null) || (statuses.length > 0)) {
7023                                    if (conjunctionable) {
7024                                            query.append(WHERE_AND);
7025                                    }
7026    
7027                                    query.append(StringPool.OPEN_PARENTHESIS);
7028    
7029                                    for (int i = 0; i < statuses.length; i++) {
7030                                            query.append(_FINDER_COLUMN_R_ST_STATUS_5);
7031    
7032                                            if ((i + 1) < statuses.length) {
7033                                                    query.append(WHERE_OR);
7034                                            }
7035                                    }
7036    
7037                                    query.append(StringPool.CLOSE_PARENTHESIS);
7038    
7039                                    conjunctionable = true;
7040                            }
7041    
7042                            String sql = query.toString();
7043    
7044                            Session session = null;
7045    
7046                            try {
7047                                    session = openSession();
7048    
7049                                    Query q = session.createQuery(sql);
7050    
7051                                    QueryPos qPos = QueryPos.getInstance(q);
7052    
7053                                    qPos.add(resourcePrimKey);
7054    
7055                                    if (statuses != null) {
7056                                            qPos.add(statuses);
7057                                    }
7058    
7059                                    count = (Long)q.uniqueResult();
7060    
7061                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_ST,
7062                                            finderArgs, count);
7063                            }
7064                            catch (Exception e) {
7065                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_ST,
7066                                            finderArgs);
7067    
7068                                    throw processException(e);
7069                            }
7070                            finally {
7071                                    closeSession(session);
7072                            }
7073                    }
7074    
7075                    return count.intValue();
7076            }
7077    
7078            private static final String _FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2 = "journalArticle.resourcePrimKey = ? AND ";
7079            private static final String _FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_5 = "(" +
7080                    removeConjunction(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2) + ")";
7081            private static final String _FINDER_COLUMN_R_ST_STATUS_2 = "journalArticle.status = ?";
7082            private static final String _FINDER_COLUMN_R_ST_STATUS_5 = "(" +
7083                    removeConjunction(_FINDER_COLUMN_R_ST_STATUS_2) + ")";
7084            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
7085                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
7086                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
7087                            "findByG_U",
7088                            new String[] {
7089                                    Long.class.getName(), Long.class.getName(),
7090                                    
7091                            Integer.class.getName(), Integer.class.getName(),
7092                                    OrderByComparator.class.getName()
7093                            });
7094            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
7095                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
7096                            JournalArticleImpl.class,
7097                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U",
7098                            new String[] { Long.class.getName(), Long.class.getName() },
7099                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
7100                            JournalArticleModelImpl.USERID_COLUMN_BITMASK |
7101                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
7102                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
7103            public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
7104                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
7105                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U",
7106                            new String[] { Long.class.getName(), Long.class.getName() });
7107    
7108            /**
7109             * Returns all the journal articles where groupId = &#63; and userId = &#63;.
7110             *
7111             * @param groupId the group ID
7112             * @param userId the user ID
7113             * @return the matching journal articles
7114             * @throws SystemException if a system exception occurred
7115             */
7116            @Override
7117            public List<JournalArticle> findByG_U(long groupId, long userId)
7118                    throws SystemException {
7119                    return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
7120                            null);
7121            }
7122    
7123            /**
7124             * Returns a range of all the journal articles where groupId = &#63; and userId = &#63;.
7125             *
7126             * <p>
7127             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7128             * </p>
7129             *
7130             * @param groupId the group ID
7131             * @param userId the user ID
7132             * @param start the lower bound of the range of journal articles
7133             * @param end the upper bound of the range of journal articles (not inclusive)
7134             * @return the range of matching journal articles
7135             * @throws SystemException if a system exception occurred
7136             */
7137            @Override
7138            public List<JournalArticle> findByG_U(long groupId, long userId, int start,
7139                    int end) throws SystemException {
7140                    return findByG_U(groupId, userId, start, end, null);
7141            }
7142    
7143            /**
7144             * Returns an ordered range of all the journal articles where groupId = &#63; and userId = &#63;.
7145             *
7146             * <p>
7147             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7148             * </p>
7149             *
7150             * @param groupId the group ID
7151             * @param userId the user ID
7152             * @param start the lower bound of the range of journal articles
7153             * @param end the upper bound of the range of journal articles (not inclusive)
7154             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7155             * @return the ordered range of matching journal articles
7156             * @throws SystemException if a system exception occurred
7157             */
7158            @Override
7159            public List<JournalArticle> findByG_U(long groupId, long userId, int start,
7160                    int end, OrderByComparator orderByComparator) throws SystemException {
7161                    boolean pagination = true;
7162                    FinderPath finderPath = null;
7163                    Object[] finderArgs = null;
7164    
7165                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7166                                    (orderByComparator == null)) {
7167                            pagination = false;
7168                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U;
7169                            finderArgs = new Object[] { groupId, userId };
7170                    }
7171                    else {
7172                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U;
7173                            finderArgs = new Object[] {
7174                                            groupId, userId,
7175                                            
7176                                            start, end, orderByComparator
7177                                    };
7178                    }
7179    
7180                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
7181                                    finderArgs, this);
7182    
7183                    if ((list != null) && !list.isEmpty()) {
7184                            for (JournalArticle journalArticle : list) {
7185                                    if ((groupId != journalArticle.getGroupId()) ||
7186                                                    (userId != journalArticle.getUserId())) {
7187                                            list = null;
7188    
7189                                            break;
7190                                    }
7191                            }
7192                    }
7193    
7194                    if (list == null) {
7195                            StringBundler query = null;
7196    
7197                            if (orderByComparator != null) {
7198                                    query = new StringBundler(4 +
7199                                                    (orderByComparator.getOrderByFields().length * 3));
7200                            }
7201                            else {
7202                                    query = new StringBundler(4);
7203                            }
7204    
7205                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7206    
7207                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7208    
7209                            query.append(_FINDER_COLUMN_G_U_USERID_2);
7210    
7211                            if (orderByComparator != null) {
7212                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7213                                            orderByComparator);
7214                            }
7215                            else
7216                             if (pagination) {
7217                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7218                            }
7219    
7220                            String sql = query.toString();
7221    
7222                            Session session = null;
7223    
7224                            try {
7225                                    session = openSession();
7226    
7227                                    Query q = session.createQuery(sql);
7228    
7229                                    QueryPos qPos = QueryPos.getInstance(q);
7230    
7231                                    qPos.add(groupId);
7232    
7233                                    qPos.add(userId);
7234    
7235                                    if (!pagination) {
7236                                            list = (List<JournalArticle>)QueryUtil.list(q,
7237                                                            getDialect(), start, end, false);
7238    
7239                                            Collections.sort(list);
7240    
7241                                            list = new UnmodifiableList<JournalArticle>(list);
7242                                    }
7243                                    else {
7244                                            list = (List<JournalArticle>)QueryUtil.list(q,
7245                                                            getDialect(), start, end);
7246                                    }
7247    
7248                                    cacheResult(list);
7249    
7250                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
7251                            }
7252                            catch (Exception e) {
7253                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7254    
7255                                    throw processException(e);
7256                            }
7257                            finally {
7258                                    closeSession(session);
7259                            }
7260                    }
7261    
7262                    return list;
7263            }
7264    
7265            /**
7266             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63;.
7267             *
7268             * @param groupId the group ID
7269             * @param userId the user ID
7270             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7271             * @return the first matching journal article
7272             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
7273             * @throws SystemException if a system exception occurred
7274             */
7275            @Override
7276            public JournalArticle findByG_U_First(long groupId, long userId,
7277                    OrderByComparator orderByComparator)
7278                    throws NoSuchArticleException, SystemException {
7279                    JournalArticle journalArticle = fetchByG_U_First(groupId, userId,
7280                                    orderByComparator);
7281    
7282                    if (journalArticle != null) {
7283                            return journalArticle;
7284                    }
7285    
7286                    StringBundler msg = new StringBundler(6);
7287    
7288                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7289    
7290                    msg.append("groupId=");
7291                    msg.append(groupId);
7292    
7293                    msg.append(", userId=");
7294                    msg.append(userId);
7295    
7296                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7297    
7298                    throw new NoSuchArticleException(msg.toString());
7299            }
7300    
7301            /**
7302             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63;.
7303             *
7304             * @param groupId the group ID
7305             * @param userId the user ID
7306             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7307             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
7308             * @throws SystemException if a system exception occurred
7309             */
7310            @Override
7311            public JournalArticle fetchByG_U_First(long groupId, long userId,
7312                    OrderByComparator orderByComparator) throws SystemException {
7313                    List<JournalArticle> list = findByG_U(groupId, userId, 0, 1,
7314                                    orderByComparator);
7315    
7316                    if (!list.isEmpty()) {
7317                            return list.get(0);
7318                    }
7319    
7320                    return null;
7321            }
7322    
7323            /**
7324             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63;.
7325             *
7326             * @param groupId the group ID
7327             * @param userId the user ID
7328             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7329             * @return the last matching journal article
7330             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
7331             * @throws SystemException if a system exception occurred
7332             */
7333            @Override
7334            public JournalArticle findByG_U_Last(long groupId, long userId,
7335                    OrderByComparator orderByComparator)
7336                    throws NoSuchArticleException, SystemException {
7337                    JournalArticle journalArticle = fetchByG_U_Last(groupId, userId,
7338                                    orderByComparator);
7339    
7340                    if (journalArticle != null) {
7341                            return journalArticle;
7342                    }
7343    
7344                    StringBundler msg = new StringBundler(6);
7345    
7346                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7347    
7348                    msg.append("groupId=");
7349                    msg.append(groupId);
7350    
7351                    msg.append(", userId=");
7352                    msg.append(userId);
7353    
7354                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7355    
7356                    throw new NoSuchArticleException(msg.toString());
7357            }
7358    
7359            /**
7360             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63;.
7361             *
7362             * @param groupId the group ID
7363             * @param userId the user ID
7364             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7365             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
7366             * @throws SystemException if a system exception occurred
7367             */
7368            @Override
7369            public JournalArticle fetchByG_U_Last(long groupId, long userId,
7370                    OrderByComparator orderByComparator) throws SystemException {
7371                    int count = countByG_U(groupId, userId);
7372    
7373                    if (count == 0) {
7374                            return null;
7375                    }
7376    
7377                    List<JournalArticle> list = findByG_U(groupId, userId, count - 1,
7378                                    count, orderByComparator);
7379    
7380                    if (!list.isEmpty()) {
7381                            return list.get(0);
7382                    }
7383    
7384                    return null;
7385            }
7386    
7387            /**
7388             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and userId = &#63;.
7389             *
7390             * @param id the primary key of the current journal article
7391             * @param groupId the group ID
7392             * @param userId the user ID
7393             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7394             * @return the previous, current, and next journal article
7395             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
7396             * @throws SystemException if a system exception occurred
7397             */
7398            @Override
7399            public JournalArticle[] findByG_U_PrevAndNext(long id, long groupId,
7400                    long userId, OrderByComparator orderByComparator)
7401                    throws NoSuchArticleException, SystemException {
7402                    JournalArticle journalArticle = findByPrimaryKey(id);
7403    
7404                    Session session = null;
7405    
7406                    try {
7407                            session = openSession();
7408    
7409                            JournalArticle[] array = new JournalArticleImpl[3];
7410    
7411                            array[0] = getByG_U_PrevAndNext(session, journalArticle, groupId,
7412                                            userId, orderByComparator, true);
7413    
7414                            array[1] = journalArticle;
7415    
7416                            array[2] = getByG_U_PrevAndNext(session, journalArticle, groupId,
7417                                            userId, orderByComparator, false);
7418    
7419                            return array;
7420                    }
7421                    catch (Exception e) {
7422                            throw processException(e);
7423                    }
7424                    finally {
7425                            closeSession(session);
7426                    }
7427            }
7428    
7429            protected JournalArticle getByG_U_PrevAndNext(Session session,
7430                    JournalArticle journalArticle, long groupId, long userId,
7431                    OrderByComparator orderByComparator, boolean previous) {
7432                    StringBundler query = null;
7433    
7434                    if (orderByComparator != null) {
7435                            query = new StringBundler(6 +
7436                                            (orderByComparator.getOrderByFields().length * 6));
7437                    }
7438                    else {
7439                            query = new StringBundler(3);
7440                    }
7441    
7442                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7443    
7444                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7445    
7446                    query.append(_FINDER_COLUMN_G_U_USERID_2);
7447    
7448                    if (orderByComparator != null) {
7449                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7450    
7451                            if (orderByConditionFields.length > 0) {
7452                                    query.append(WHERE_AND);
7453                            }
7454    
7455                            for (int i = 0; i < orderByConditionFields.length; i++) {
7456                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7457                                    query.append(orderByConditionFields[i]);
7458    
7459                                    if ((i + 1) < orderByConditionFields.length) {
7460                                            if (orderByComparator.isAscending() ^ previous) {
7461                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7462                                            }
7463                                            else {
7464                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7465                                            }
7466                                    }
7467                                    else {
7468                                            if (orderByComparator.isAscending() ^ previous) {
7469                                                    query.append(WHERE_GREATER_THAN);
7470                                            }
7471                                            else {
7472                                                    query.append(WHERE_LESSER_THAN);
7473                                            }
7474                                    }
7475                            }
7476    
7477                            query.append(ORDER_BY_CLAUSE);
7478    
7479                            String[] orderByFields = orderByComparator.getOrderByFields();
7480    
7481                            for (int i = 0; i < orderByFields.length; i++) {
7482                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7483                                    query.append(orderByFields[i]);
7484    
7485                                    if ((i + 1) < orderByFields.length) {
7486                                            if (orderByComparator.isAscending() ^ previous) {
7487                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7488                                            }
7489                                            else {
7490                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7491                                            }
7492                                    }
7493                                    else {
7494                                            if (orderByComparator.isAscending() ^ previous) {
7495                                                    query.append(ORDER_BY_ASC);
7496                                            }
7497                                            else {
7498                                                    query.append(ORDER_BY_DESC);
7499                                            }
7500                                    }
7501                            }
7502                    }
7503                    else {
7504                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7505                    }
7506    
7507                    String sql = query.toString();
7508    
7509                    Query q = session.createQuery(sql);
7510    
7511                    q.setFirstResult(0);
7512                    q.setMaxResults(2);
7513    
7514                    QueryPos qPos = QueryPos.getInstance(q);
7515    
7516                    qPos.add(groupId);
7517    
7518                    qPos.add(userId);
7519    
7520                    if (orderByComparator != null) {
7521                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7522    
7523                            for (Object value : values) {
7524                                    qPos.add(value);
7525                            }
7526                    }
7527    
7528                    List<JournalArticle> list = q.list();
7529    
7530                    if (list.size() == 2) {
7531                            return list.get(1);
7532                    }
7533                    else {
7534                            return null;
7535                    }
7536            }
7537    
7538            /**
7539             * Returns all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
7540             *
7541             * @param groupId the group ID
7542             * @param userId the user ID
7543             * @return the matching journal articles that the user has permission to view
7544             * @throws SystemException if a system exception occurred
7545             */
7546            @Override
7547            public List<JournalArticle> filterFindByG_U(long groupId, long userId)
7548                    throws SystemException {
7549                    return filterFindByG_U(groupId, userId, QueryUtil.ALL_POS,
7550                            QueryUtil.ALL_POS, null);
7551            }
7552    
7553            /**
7554             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
7555             *
7556             * <p>
7557             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7558             * </p>
7559             *
7560             * @param groupId the group ID
7561             * @param userId the user ID
7562             * @param start the lower bound of the range of journal articles
7563             * @param end the upper bound of the range of journal articles (not inclusive)
7564             * @return the range of matching journal articles that the user has permission to view
7565             * @throws SystemException if a system exception occurred
7566             */
7567            @Override
7568            public List<JournalArticle> filterFindByG_U(long groupId, long userId,
7569                    int start, int end) throws SystemException {
7570                    return filterFindByG_U(groupId, userId, start, end, null);
7571            }
7572    
7573            /**
7574             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and userId = &#63;.
7575             *
7576             * <p>
7577             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7578             * </p>
7579             *
7580             * @param groupId the group ID
7581             * @param userId the user ID
7582             * @param start the lower bound of the range of journal articles
7583             * @param end the upper bound of the range of journal articles (not inclusive)
7584             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7585             * @return the ordered range of matching journal articles that the user has permission to view
7586             * @throws SystemException if a system exception occurred
7587             */
7588            @Override
7589            public List<JournalArticle> filterFindByG_U(long groupId, long userId,
7590                    int start, int end, OrderByComparator orderByComparator)
7591                    throws SystemException {
7592                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7593                            return findByG_U(groupId, userId, start, end, orderByComparator);
7594                    }
7595    
7596                    StringBundler query = null;
7597    
7598                    if (orderByComparator != null) {
7599                            query = new StringBundler(4 +
7600                                            (orderByComparator.getOrderByFields().length * 3));
7601                    }
7602                    else {
7603                            query = new StringBundler(4);
7604                    }
7605    
7606                    if (getDB().isSupportsInlineDistinct()) {
7607                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7608                    }
7609                    else {
7610                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7611                    }
7612    
7613                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7614    
7615                    query.append(_FINDER_COLUMN_G_U_USERID_2);
7616    
7617                    if (!getDB().isSupportsInlineDistinct()) {
7618                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7619                    }
7620    
7621                    if (orderByComparator != null) {
7622                            if (getDB().isSupportsInlineDistinct()) {
7623                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7624                                            orderByComparator, true);
7625                            }
7626                            else {
7627                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7628                                            orderByComparator, true);
7629                            }
7630                    }
7631                    else {
7632                            if (getDB().isSupportsInlineDistinct()) {
7633                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7634                            }
7635                            else {
7636                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7637                            }
7638                    }
7639    
7640                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7641                                    JournalArticle.class.getName(),
7642                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7643    
7644                    Session session = null;
7645    
7646                    try {
7647                            session = openSession();
7648    
7649                            SQLQuery q = session.createSQLQuery(sql);
7650    
7651                            if (getDB().isSupportsInlineDistinct()) {
7652                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7653                            }
7654                            else {
7655                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7656                            }
7657    
7658                            QueryPos qPos = QueryPos.getInstance(q);
7659    
7660                            qPos.add(groupId);
7661    
7662                            qPos.add(userId);
7663    
7664                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
7665                                    end);
7666                    }
7667                    catch (Exception e) {
7668                            throw processException(e);
7669                    }
7670                    finally {
7671                            closeSession(session);
7672                    }
7673            }
7674    
7675            /**
7676             * 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;.
7677             *
7678             * @param id the primary key of the current journal article
7679             * @param groupId the group ID
7680             * @param userId the user ID
7681             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7682             * @return the previous, current, and next journal article
7683             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
7684             * @throws SystemException if a system exception occurred
7685             */
7686            @Override
7687            public JournalArticle[] filterFindByG_U_PrevAndNext(long id, long groupId,
7688                    long userId, OrderByComparator orderByComparator)
7689                    throws NoSuchArticleException, SystemException {
7690                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7691                            return findByG_U_PrevAndNext(id, groupId, userId, orderByComparator);
7692                    }
7693    
7694                    JournalArticle journalArticle = findByPrimaryKey(id);
7695    
7696                    Session session = null;
7697    
7698                    try {
7699                            session = openSession();
7700    
7701                            JournalArticle[] array = new JournalArticleImpl[3];
7702    
7703                            array[0] = filterGetByG_U_PrevAndNext(session, journalArticle,
7704                                            groupId, userId, orderByComparator, true);
7705    
7706                            array[1] = journalArticle;
7707    
7708                            array[2] = filterGetByG_U_PrevAndNext(session, journalArticle,
7709                                            groupId, userId, orderByComparator, false);
7710    
7711                            return array;
7712                    }
7713                    catch (Exception e) {
7714                            throw processException(e);
7715                    }
7716                    finally {
7717                            closeSession(session);
7718                    }
7719            }
7720    
7721            protected JournalArticle filterGetByG_U_PrevAndNext(Session session,
7722                    JournalArticle journalArticle, long groupId, long userId,
7723                    OrderByComparator orderByComparator, boolean previous) {
7724                    StringBundler query = null;
7725    
7726                    if (orderByComparator != null) {
7727                            query = new StringBundler(6 +
7728                                            (orderByComparator.getOrderByFields().length * 6));
7729                    }
7730                    else {
7731                            query = new StringBundler(3);
7732                    }
7733    
7734                    if (getDB().isSupportsInlineDistinct()) {
7735                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7736                    }
7737                    else {
7738                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7739                    }
7740    
7741                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7742    
7743                    query.append(_FINDER_COLUMN_G_U_USERID_2);
7744    
7745                    if (!getDB().isSupportsInlineDistinct()) {
7746                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7747                    }
7748    
7749                    if (orderByComparator != null) {
7750                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7751    
7752                            if (orderByConditionFields.length > 0) {
7753                                    query.append(WHERE_AND);
7754                            }
7755    
7756                            for (int i = 0; i < orderByConditionFields.length; i++) {
7757                                    if (getDB().isSupportsInlineDistinct()) {
7758                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7759                                    }
7760                                    else {
7761                                            query.append(_ORDER_BY_ENTITY_TABLE);
7762                                    }
7763    
7764                                    query.append(orderByConditionFields[i]);
7765    
7766                                    if ((i + 1) < orderByConditionFields.length) {
7767                                            if (orderByComparator.isAscending() ^ previous) {
7768                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7769                                            }
7770                                            else {
7771                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7772                                            }
7773                                    }
7774                                    else {
7775                                            if (orderByComparator.isAscending() ^ previous) {
7776                                                    query.append(WHERE_GREATER_THAN);
7777                                            }
7778                                            else {
7779                                                    query.append(WHERE_LESSER_THAN);
7780                                            }
7781                                    }
7782                            }
7783    
7784                            query.append(ORDER_BY_CLAUSE);
7785    
7786                            String[] orderByFields = orderByComparator.getOrderByFields();
7787    
7788                            for (int i = 0; i < orderByFields.length; i++) {
7789                                    if (getDB().isSupportsInlineDistinct()) {
7790                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7791                                    }
7792                                    else {
7793                                            query.append(_ORDER_BY_ENTITY_TABLE);
7794                                    }
7795    
7796                                    query.append(orderByFields[i]);
7797    
7798                                    if ((i + 1) < orderByFields.length) {
7799                                            if (orderByComparator.isAscending() ^ previous) {
7800                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7801                                            }
7802                                            else {
7803                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7804                                            }
7805                                    }
7806                                    else {
7807                                            if (orderByComparator.isAscending() ^ previous) {
7808                                                    query.append(ORDER_BY_ASC);
7809                                            }
7810                                            else {
7811                                                    query.append(ORDER_BY_DESC);
7812                                            }
7813                                    }
7814                            }
7815                    }
7816                    else {
7817                            if (getDB().isSupportsInlineDistinct()) {
7818                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7819                            }
7820                            else {
7821                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7822                            }
7823                    }
7824    
7825                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7826                                    JournalArticle.class.getName(),
7827                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7828    
7829                    SQLQuery q = session.createSQLQuery(sql);
7830    
7831                    q.setFirstResult(0);
7832                    q.setMaxResults(2);
7833    
7834                    if (getDB().isSupportsInlineDistinct()) {
7835                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7836                    }
7837                    else {
7838                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7839                    }
7840    
7841                    QueryPos qPos = QueryPos.getInstance(q);
7842    
7843                    qPos.add(groupId);
7844    
7845                    qPos.add(userId);
7846    
7847                    if (orderByComparator != null) {
7848                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7849    
7850                            for (Object value : values) {
7851                                    qPos.add(value);
7852                            }
7853                    }
7854    
7855                    List<JournalArticle> list = q.list();
7856    
7857                    if (list.size() == 2) {
7858                            return list.get(1);
7859                    }
7860                    else {
7861                            return null;
7862                    }
7863            }
7864    
7865            /**
7866             * Removes all the journal articles where groupId = &#63; and userId = &#63; from the database.
7867             *
7868             * @param groupId the group ID
7869             * @param userId the user ID
7870             * @throws SystemException if a system exception occurred
7871             */
7872            @Override
7873            public void removeByG_U(long groupId, long userId)
7874                    throws SystemException {
7875                    for (JournalArticle journalArticle : findByG_U(groupId, userId,
7876                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7877                            remove(journalArticle);
7878                    }
7879            }
7880    
7881            /**
7882             * Returns the number of journal articles where groupId = &#63; and userId = &#63;.
7883             *
7884             * @param groupId the group ID
7885             * @param userId the user ID
7886             * @return the number of matching journal articles
7887             * @throws SystemException if a system exception occurred
7888             */
7889            @Override
7890            public int countByG_U(long groupId, long userId) throws SystemException {
7891                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U;
7892    
7893                    Object[] finderArgs = new Object[] { groupId, userId };
7894    
7895                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7896                                    this);
7897    
7898                    if (count == null) {
7899                            StringBundler query = new StringBundler(3);
7900    
7901                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
7902    
7903                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7904    
7905                            query.append(_FINDER_COLUMN_G_U_USERID_2);
7906    
7907                            String sql = query.toString();
7908    
7909                            Session session = null;
7910    
7911                            try {
7912                                    session = openSession();
7913    
7914                                    Query q = session.createQuery(sql);
7915    
7916                                    QueryPos qPos = QueryPos.getInstance(q);
7917    
7918                                    qPos.add(groupId);
7919    
7920                                    qPos.add(userId);
7921    
7922                                    count = (Long)q.uniqueResult();
7923    
7924                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
7925                            }
7926                            catch (Exception e) {
7927                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7928    
7929                                    throw processException(e);
7930                            }
7931                            finally {
7932                                    closeSession(session);
7933                            }
7934                    }
7935    
7936                    return count.intValue();
7937            }
7938    
7939            /**
7940             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
7941             *
7942             * @param groupId the group ID
7943             * @param userId the user ID
7944             * @return the number of matching journal articles that the user has permission to view
7945             * @throws SystemException if a system exception occurred
7946             */
7947            @Override
7948            public int filterCountByG_U(long groupId, long userId)
7949                    throws SystemException {
7950                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7951                            return countByG_U(groupId, userId);
7952                    }
7953    
7954                    StringBundler query = new StringBundler(3);
7955    
7956                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
7957    
7958                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7959    
7960                    query.append(_FINDER_COLUMN_G_U_USERID_2);
7961    
7962                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7963                                    JournalArticle.class.getName(),
7964                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7965    
7966                    Session session = null;
7967    
7968                    try {
7969                            session = openSession();
7970    
7971                            SQLQuery q = session.createSQLQuery(sql);
7972    
7973                            q.addScalar(COUNT_COLUMN_NAME,
7974                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
7975    
7976                            QueryPos qPos = QueryPos.getInstance(q);
7977    
7978                            qPos.add(groupId);
7979    
7980                            qPos.add(userId);
7981    
7982                            Long count = (Long)q.uniqueResult();
7983    
7984                            return count.intValue();
7985                    }
7986                    catch (Exception e) {
7987                            throw processException(e);
7988                    }
7989                    finally {
7990                            closeSession(session);
7991                    }
7992            }
7993    
7994            private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "journalArticle.groupId = ? AND ";
7995            private static final String _FINDER_COLUMN_G_U_USERID_2 = "journalArticle.userId = ?";
7996            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
7997                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
7998                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
7999                            "findByG_F",
8000                            new String[] {
8001                                    Long.class.getName(), Long.class.getName(),
8002                                    
8003                            Integer.class.getName(), Integer.class.getName(),
8004                                    OrderByComparator.class.getName()
8005                            });
8006            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
8007                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
8008                            JournalArticleImpl.class,
8009                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F",
8010                            new String[] { Long.class.getName(), Long.class.getName() },
8011                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
8012                            JournalArticleModelImpl.FOLDERID_COLUMN_BITMASK |
8013                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
8014                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
8015            public static final FinderPath FINDER_PATH_COUNT_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
8016                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
8017                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F",
8018                            new String[] { Long.class.getName(), Long.class.getName() });
8019            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
8020                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
8021                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F",
8022                            new String[] { Long.class.getName(), Long.class.getName() });
8023    
8024            /**
8025             * Returns all the journal articles where groupId = &#63; and folderId = &#63;.
8026             *
8027             * @param groupId the group ID
8028             * @param folderId the folder ID
8029             * @return the matching journal articles
8030             * @throws SystemException if a system exception occurred
8031             */
8032            @Override
8033            public List<JournalArticle> findByG_F(long groupId, long folderId)
8034                    throws SystemException {
8035                    return findByG_F(groupId, folderId, QueryUtil.ALL_POS,
8036                            QueryUtil.ALL_POS, null);
8037            }
8038    
8039            /**
8040             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63;.
8041             *
8042             * <p>
8043             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8044             * </p>
8045             *
8046             * @param groupId the group ID
8047             * @param folderId the folder ID
8048             * @param start the lower bound of the range of journal articles
8049             * @param end the upper bound of the range of journal articles (not inclusive)
8050             * @return the range of matching journal articles
8051             * @throws SystemException if a system exception occurred
8052             */
8053            @Override
8054            public List<JournalArticle> findByG_F(long groupId, long folderId,
8055                    int start, int end) throws SystemException {
8056                    return findByG_F(groupId, folderId, start, end, null);
8057            }
8058    
8059            /**
8060             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63;.
8061             *
8062             * <p>
8063             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8064             * </p>
8065             *
8066             * @param groupId the group ID
8067             * @param folderId the folder ID
8068             * @param start the lower bound of the range of journal articles
8069             * @param end the upper bound of the range of journal articles (not inclusive)
8070             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8071             * @return the ordered range of matching journal articles
8072             * @throws SystemException if a system exception occurred
8073             */
8074            @Override
8075            public List<JournalArticle> findByG_F(long groupId, long folderId,
8076                    int start, int end, OrderByComparator orderByComparator)
8077                    throws SystemException {
8078                    boolean pagination = true;
8079                    FinderPath finderPath = null;
8080                    Object[] finderArgs = null;
8081    
8082                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8083                                    (orderByComparator == null)) {
8084                            pagination = false;
8085                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F;
8086                            finderArgs = new Object[] { groupId, folderId };
8087                    }
8088                    else {
8089                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F;
8090                            finderArgs = new Object[] {
8091                                            groupId, folderId,
8092                                            
8093                                            start, end, orderByComparator
8094                                    };
8095                    }
8096    
8097                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
8098                                    finderArgs, this);
8099    
8100                    if ((list != null) && !list.isEmpty()) {
8101                            for (JournalArticle journalArticle : list) {
8102                                    if ((groupId != journalArticle.getGroupId()) ||
8103                                                    (folderId != journalArticle.getFolderId())) {
8104                                            list = null;
8105    
8106                                            break;
8107                                    }
8108                            }
8109                    }
8110    
8111                    if (list == null) {
8112                            StringBundler query = null;
8113    
8114                            if (orderByComparator != null) {
8115                                    query = new StringBundler(4 +
8116                                                    (orderByComparator.getOrderByFields().length * 3));
8117                            }
8118                            else {
8119                                    query = new StringBundler(4);
8120                            }
8121    
8122                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8123    
8124                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8125    
8126                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
8127    
8128                            if (orderByComparator != null) {
8129                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8130                                            orderByComparator);
8131                            }
8132                            else
8133                             if (pagination) {
8134                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8135                            }
8136    
8137                            String sql = query.toString();
8138    
8139                            Session session = null;
8140    
8141                            try {
8142                                    session = openSession();
8143    
8144                                    Query q = session.createQuery(sql);
8145    
8146                                    QueryPos qPos = QueryPos.getInstance(q);
8147    
8148                                    qPos.add(groupId);
8149    
8150                                    qPos.add(folderId);
8151    
8152                                    if (!pagination) {
8153                                            list = (List<JournalArticle>)QueryUtil.list(q,
8154                                                            getDialect(), start, end, false);
8155    
8156                                            Collections.sort(list);
8157    
8158                                            list = new UnmodifiableList<JournalArticle>(list);
8159                                    }
8160                                    else {
8161                                            list = (List<JournalArticle>)QueryUtil.list(q,
8162                                                            getDialect(), start, end);
8163                                    }
8164    
8165                                    cacheResult(list);
8166    
8167                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
8168                            }
8169                            catch (Exception e) {
8170                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8171    
8172                                    throw processException(e);
8173                            }
8174                            finally {
8175                                    closeSession(session);
8176                            }
8177                    }
8178    
8179                    return list;
8180            }
8181    
8182            /**
8183             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63;.
8184             *
8185             * @param groupId the group ID
8186             * @param folderId the folder ID
8187             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8188             * @return the first matching journal article
8189             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
8190             * @throws SystemException if a system exception occurred
8191             */
8192            @Override
8193            public JournalArticle findByG_F_First(long groupId, long folderId,
8194                    OrderByComparator orderByComparator)
8195                    throws NoSuchArticleException, SystemException {
8196                    JournalArticle journalArticle = fetchByG_F_First(groupId, folderId,
8197                                    orderByComparator);
8198    
8199                    if (journalArticle != null) {
8200                            return journalArticle;
8201                    }
8202    
8203                    StringBundler msg = new StringBundler(6);
8204    
8205                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8206    
8207                    msg.append("groupId=");
8208                    msg.append(groupId);
8209    
8210                    msg.append(", folderId=");
8211                    msg.append(folderId);
8212    
8213                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8214    
8215                    throw new NoSuchArticleException(msg.toString());
8216            }
8217    
8218            /**
8219             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63;.
8220             *
8221             * @param groupId the group ID
8222             * @param folderId the folder ID
8223             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8224             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
8225             * @throws SystemException if a system exception occurred
8226             */
8227            @Override
8228            public JournalArticle fetchByG_F_First(long groupId, long folderId,
8229                    OrderByComparator orderByComparator) throws SystemException {
8230                    List<JournalArticle> list = findByG_F(groupId, folderId, 0, 1,
8231                                    orderByComparator);
8232    
8233                    if (!list.isEmpty()) {
8234                            return list.get(0);
8235                    }
8236    
8237                    return null;
8238            }
8239    
8240            /**
8241             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63;.
8242             *
8243             * @param groupId the group ID
8244             * @param folderId the folder ID
8245             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8246             * @return the last matching journal article
8247             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
8248             * @throws SystemException if a system exception occurred
8249             */
8250            @Override
8251            public JournalArticle findByG_F_Last(long groupId, long folderId,
8252                    OrderByComparator orderByComparator)
8253                    throws NoSuchArticleException, SystemException {
8254                    JournalArticle journalArticle = fetchByG_F_Last(groupId, folderId,
8255                                    orderByComparator);
8256    
8257                    if (journalArticle != null) {
8258                            return journalArticle;
8259                    }
8260    
8261                    StringBundler msg = new StringBundler(6);
8262    
8263                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8264    
8265                    msg.append("groupId=");
8266                    msg.append(groupId);
8267    
8268                    msg.append(", folderId=");
8269                    msg.append(folderId);
8270    
8271                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8272    
8273                    throw new NoSuchArticleException(msg.toString());
8274            }
8275    
8276            /**
8277             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63;.
8278             *
8279             * @param groupId the group ID
8280             * @param folderId the folder ID
8281             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8282             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
8283             * @throws SystemException if a system exception occurred
8284             */
8285            @Override
8286            public JournalArticle fetchByG_F_Last(long groupId, long folderId,
8287                    OrderByComparator orderByComparator) throws SystemException {
8288                    int count = countByG_F(groupId, folderId);
8289    
8290                    if (count == 0) {
8291                            return null;
8292                    }
8293    
8294                    List<JournalArticle> list = findByG_F(groupId, folderId, count - 1,
8295                                    count, orderByComparator);
8296    
8297                    if (!list.isEmpty()) {
8298                            return list.get(0);
8299                    }
8300    
8301                    return null;
8302            }
8303    
8304            /**
8305             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and folderId = &#63;.
8306             *
8307             * @param id the primary key of the current journal article
8308             * @param groupId the group ID
8309             * @param folderId the folder ID
8310             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8311             * @return the previous, current, and next journal article
8312             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
8313             * @throws SystemException if a system exception occurred
8314             */
8315            @Override
8316            public JournalArticle[] findByG_F_PrevAndNext(long id, long groupId,
8317                    long folderId, OrderByComparator orderByComparator)
8318                    throws NoSuchArticleException, SystemException {
8319                    JournalArticle journalArticle = findByPrimaryKey(id);
8320    
8321                    Session session = null;
8322    
8323                    try {
8324                            session = openSession();
8325    
8326                            JournalArticle[] array = new JournalArticleImpl[3];
8327    
8328                            array[0] = getByG_F_PrevAndNext(session, journalArticle, groupId,
8329                                            folderId, orderByComparator, true);
8330    
8331                            array[1] = journalArticle;
8332    
8333                            array[2] = getByG_F_PrevAndNext(session, journalArticle, groupId,
8334                                            folderId, orderByComparator, false);
8335    
8336                            return array;
8337                    }
8338                    catch (Exception e) {
8339                            throw processException(e);
8340                    }
8341                    finally {
8342                            closeSession(session);
8343                    }
8344            }
8345    
8346            protected JournalArticle getByG_F_PrevAndNext(Session session,
8347                    JournalArticle journalArticle, long groupId, long folderId,
8348                    OrderByComparator orderByComparator, boolean previous) {
8349                    StringBundler query = null;
8350    
8351                    if (orderByComparator != null) {
8352                            query = new StringBundler(6 +
8353                                            (orderByComparator.getOrderByFields().length * 6));
8354                    }
8355                    else {
8356                            query = new StringBundler(3);
8357                    }
8358    
8359                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8360    
8361                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8362    
8363                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
8364    
8365                    if (orderByComparator != null) {
8366                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8367    
8368                            if (orderByConditionFields.length > 0) {
8369                                    query.append(WHERE_AND);
8370                            }
8371    
8372                            for (int i = 0; i < orderByConditionFields.length; i++) {
8373                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8374                                    query.append(orderByConditionFields[i]);
8375    
8376                                    if ((i + 1) < orderByConditionFields.length) {
8377                                            if (orderByComparator.isAscending() ^ previous) {
8378                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8379                                            }
8380                                            else {
8381                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8382                                            }
8383                                    }
8384                                    else {
8385                                            if (orderByComparator.isAscending() ^ previous) {
8386                                                    query.append(WHERE_GREATER_THAN);
8387                                            }
8388                                            else {
8389                                                    query.append(WHERE_LESSER_THAN);
8390                                            }
8391                                    }
8392                            }
8393    
8394                            query.append(ORDER_BY_CLAUSE);
8395    
8396                            String[] orderByFields = orderByComparator.getOrderByFields();
8397    
8398                            for (int i = 0; i < orderByFields.length; i++) {
8399                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8400                                    query.append(orderByFields[i]);
8401    
8402                                    if ((i + 1) < orderByFields.length) {
8403                                            if (orderByComparator.isAscending() ^ previous) {
8404                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8405                                            }
8406                                            else {
8407                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8408                                            }
8409                                    }
8410                                    else {
8411                                            if (orderByComparator.isAscending() ^ previous) {
8412                                                    query.append(ORDER_BY_ASC);
8413                                            }
8414                                            else {
8415                                                    query.append(ORDER_BY_DESC);
8416                                            }
8417                                    }
8418                            }
8419                    }
8420                    else {
8421                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8422                    }
8423    
8424                    String sql = query.toString();
8425    
8426                    Query q = session.createQuery(sql);
8427    
8428                    q.setFirstResult(0);
8429                    q.setMaxResults(2);
8430    
8431                    QueryPos qPos = QueryPos.getInstance(q);
8432    
8433                    qPos.add(groupId);
8434    
8435                    qPos.add(folderId);
8436    
8437                    if (orderByComparator != null) {
8438                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
8439    
8440                            for (Object value : values) {
8441                                    qPos.add(value);
8442                            }
8443                    }
8444    
8445                    List<JournalArticle> list = q.list();
8446    
8447                    if (list.size() == 2) {
8448                            return list.get(1);
8449                    }
8450                    else {
8451                            return null;
8452                    }
8453            }
8454    
8455            /**
8456             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
8457             *
8458             * @param groupId the group ID
8459             * @param folderId the folder ID
8460             * @return the matching journal articles that the user has permission to view
8461             * @throws SystemException if a system exception occurred
8462             */
8463            @Override
8464            public List<JournalArticle> filterFindByG_F(long groupId, long folderId)
8465                    throws SystemException {
8466                    return filterFindByG_F(groupId, folderId, QueryUtil.ALL_POS,
8467                            QueryUtil.ALL_POS, null);
8468            }
8469    
8470            /**
8471             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
8472             *
8473             * <p>
8474             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8475             * </p>
8476             *
8477             * @param groupId the group ID
8478             * @param folderId the folder ID
8479             * @param start the lower bound of the range of journal articles
8480             * @param end the upper bound of the range of journal articles (not inclusive)
8481             * @return the range of matching journal articles that the user has permission to view
8482             * @throws SystemException if a system exception occurred
8483             */
8484            @Override
8485            public List<JournalArticle> filterFindByG_F(long groupId, long folderId,
8486                    int start, int end) throws SystemException {
8487                    return filterFindByG_F(groupId, folderId, start, end, null);
8488            }
8489    
8490            /**
8491             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and folderId = &#63;.
8492             *
8493             * <p>
8494             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8495             * </p>
8496             *
8497             * @param groupId the group ID
8498             * @param folderId the folder ID
8499             * @param start the lower bound of the range of journal articles
8500             * @param end the upper bound of the range of journal articles (not inclusive)
8501             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8502             * @return the ordered range of matching journal articles that the user has permission to view
8503             * @throws SystemException if a system exception occurred
8504             */
8505            @Override
8506            public List<JournalArticle> filterFindByG_F(long groupId, long folderId,
8507                    int start, int end, OrderByComparator orderByComparator)
8508                    throws SystemException {
8509                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8510                            return findByG_F(groupId, folderId, start, end, orderByComparator);
8511                    }
8512    
8513                    StringBundler query = null;
8514    
8515                    if (orderByComparator != null) {
8516                            query = new StringBundler(4 +
8517                                            (orderByComparator.getOrderByFields().length * 3));
8518                    }
8519                    else {
8520                            query = new StringBundler(4);
8521                    }
8522    
8523                    if (getDB().isSupportsInlineDistinct()) {
8524                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8525                    }
8526                    else {
8527                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8528                    }
8529    
8530                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8531    
8532                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
8533    
8534                    if (!getDB().isSupportsInlineDistinct()) {
8535                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8536                    }
8537    
8538                    if (orderByComparator != null) {
8539                            if (getDB().isSupportsInlineDistinct()) {
8540                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8541                                            orderByComparator, true);
8542                            }
8543                            else {
8544                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8545                                            orderByComparator, true);
8546                            }
8547                    }
8548                    else {
8549                            if (getDB().isSupportsInlineDistinct()) {
8550                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8551                            }
8552                            else {
8553                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8554                            }
8555                    }
8556    
8557                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8558                                    JournalArticle.class.getName(),
8559                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8560    
8561                    Session session = null;
8562    
8563                    try {
8564                            session = openSession();
8565    
8566                            SQLQuery q = session.createSQLQuery(sql);
8567    
8568                            if (getDB().isSupportsInlineDistinct()) {
8569                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8570                            }
8571                            else {
8572                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8573                            }
8574    
8575                            QueryPos qPos = QueryPos.getInstance(q);
8576    
8577                            qPos.add(groupId);
8578    
8579                            qPos.add(folderId);
8580    
8581                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
8582                                    end);
8583                    }
8584                    catch (Exception e) {
8585                            throw processException(e);
8586                    }
8587                    finally {
8588                            closeSession(session);
8589                    }
8590            }
8591    
8592            /**
8593             * 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;.
8594             *
8595             * @param id the primary key of the current journal article
8596             * @param groupId the group ID
8597             * @param folderId the folder ID
8598             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8599             * @return the previous, current, and next journal article
8600             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
8601             * @throws SystemException if a system exception occurred
8602             */
8603            @Override
8604            public JournalArticle[] filterFindByG_F_PrevAndNext(long id, long groupId,
8605                    long folderId, OrderByComparator orderByComparator)
8606                    throws NoSuchArticleException, SystemException {
8607                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8608                            return findByG_F_PrevAndNext(id, groupId, folderId,
8609                                    orderByComparator);
8610                    }
8611    
8612                    JournalArticle journalArticle = findByPrimaryKey(id);
8613    
8614                    Session session = null;
8615    
8616                    try {
8617                            session = openSession();
8618    
8619                            JournalArticle[] array = new JournalArticleImpl[3];
8620    
8621                            array[0] = filterGetByG_F_PrevAndNext(session, journalArticle,
8622                                            groupId, folderId, orderByComparator, true);
8623    
8624                            array[1] = journalArticle;
8625    
8626                            array[2] = filterGetByG_F_PrevAndNext(session, journalArticle,
8627                                            groupId, folderId, orderByComparator, false);
8628    
8629                            return array;
8630                    }
8631                    catch (Exception e) {
8632                            throw processException(e);
8633                    }
8634                    finally {
8635                            closeSession(session);
8636                    }
8637            }
8638    
8639            protected JournalArticle filterGetByG_F_PrevAndNext(Session session,
8640                    JournalArticle journalArticle, long groupId, long folderId,
8641                    OrderByComparator orderByComparator, boolean previous) {
8642                    StringBundler query = null;
8643    
8644                    if (orderByComparator != null) {
8645                            query = new StringBundler(6 +
8646                                            (orderByComparator.getOrderByFields().length * 6));
8647                    }
8648                    else {
8649                            query = new StringBundler(3);
8650                    }
8651    
8652                    if (getDB().isSupportsInlineDistinct()) {
8653                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8654                    }
8655                    else {
8656                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8657                    }
8658    
8659                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8660    
8661                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
8662    
8663                    if (!getDB().isSupportsInlineDistinct()) {
8664                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8665                    }
8666    
8667                    if (orderByComparator != null) {
8668                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8669    
8670                            if (orderByConditionFields.length > 0) {
8671                                    query.append(WHERE_AND);
8672                            }
8673    
8674                            for (int i = 0; i < orderByConditionFields.length; i++) {
8675                                    if (getDB().isSupportsInlineDistinct()) {
8676                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8677                                    }
8678                                    else {
8679                                            query.append(_ORDER_BY_ENTITY_TABLE);
8680                                    }
8681    
8682                                    query.append(orderByConditionFields[i]);
8683    
8684                                    if ((i + 1) < orderByConditionFields.length) {
8685                                            if (orderByComparator.isAscending() ^ previous) {
8686                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8687                                            }
8688                                            else {
8689                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8690                                            }
8691                                    }
8692                                    else {
8693                                            if (orderByComparator.isAscending() ^ previous) {
8694                                                    query.append(WHERE_GREATER_THAN);
8695                                            }
8696                                            else {
8697                                                    query.append(WHERE_LESSER_THAN);
8698                                            }
8699                                    }
8700                            }
8701    
8702                            query.append(ORDER_BY_CLAUSE);
8703    
8704                            String[] orderByFields = orderByComparator.getOrderByFields();
8705    
8706                            for (int i = 0; i < orderByFields.length; i++) {
8707                                    if (getDB().isSupportsInlineDistinct()) {
8708                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8709                                    }
8710                                    else {
8711                                            query.append(_ORDER_BY_ENTITY_TABLE);
8712                                    }
8713    
8714                                    query.append(orderByFields[i]);
8715    
8716                                    if ((i + 1) < orderByFields.length) {
8717                                            if (orderByComparator.isAscending() ^ previous) {
8718                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8719                                            }
8720                                            else {
8721                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8722                                            }
8723                                    }
8724                                    else {
8725                                            if (orderByComparator.isAscending() ^ previous) {
8726                                                    query.append(ORDER_BY_ASC);
8727                                            }
8728                                            else {
8729                                                    query.append(ORDER_BY_DESC);
8730                                            }
8731                                    }
8732                            }
8733                    }
8734                    else {
8735                            if (getDB().isSupportsInlineDistinct()) {
8736                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8737                            }
8738                            else {
8739                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8740                            }
8741                    }
8742    
8743                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8744                                    JournalArticle.class.getName(),
8745                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8746    
8747                    SQLQuery q = session.createSQLQuery(sql);
8748    
8749                    q.setFirstResult(0);
8750                    q.setMaxResults(2);
8751    
8752                    if (getDB().isSupportsInlineDistinct()) {
8753                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8754                    }
8755                    else {
8756                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8757                    }
8758    
8759                    QueryPos qPos = QueryPos.getInstance(q);
8760    
8761                    qPos.add(groupId);
8762    
8763                    qPos.add(folderId);
8764    
8765                    if (orderByComparator != null) {
8766                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
8767    
8768                            for (Object value : values) {
8769                                    qPos.add(value);
8770                            }
8771                    }
8772    
8773                    List<JournalArticle> list = q.list();
8774    
8775                    if (list.size() == 2) {
8776                            return list.get(1);
8777                    }
8778                    else {
8779                            return null;
8780                    }
8781            }
8782    
8783            /**
8784             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
8785             *
8786             * @param groupId the group ID
8787             * @param folderIds the folder IDs
8788             * @return the matching journal articles that the user has permission to view
8789             * @throws SystemException if a system exception occurred
8790             */
8791            @Override
8792            public List<JournalArticle> filterFindByG_F(long groupId, long[] folderIds)
8793                    throws SystemException {
8794                    return filterFindByG_F(groupId, folderIds, QueryUtil.ALL_POS,
8795                            QueryUtil.ALL_POS, null);
8796            }
8797    
8798            /**
8799             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
8800             *
8801             * <p>
8802             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8803             * </p>
8804             *
8805             * @param groupId the group ID
8806             * @param folderIds the folder IDs
8807             * @param start the lower bound of the range of journal articles
8808             * @param end the upper bound of the range of journal articles (not inclusive)
8809             * @return the range of matching journal articles that the user has permission to view
8810             * @throws SystemException if a system exception occurred
8811             */
8812            @Override
8813            public List<JournalArticle> filterFindByG_F(long groupId, long[] folderIds,
8814                    int start, int end) throws SystemException {
8815                    return filterFindByG_F(groupId, folderIds, start, end, null);
8816            }
8817    
8818            /**
8819             * Returns an ordered range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
8820             *
8821             * <p>
8822             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8823             * </p>
8824             *
8825             * @param groupId the group ID
8826             * @param folderIds the folder IDs
8827             * @param start the lower bound of the range of journal articles
8828             * @param end the upper bound of the range of journal articles (not inclusive)
8829             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8830             * @return the ordered range of matching journal articles that the user has permission to view
8831             * @throws SystemException if a system exception occurred
8832             */
8833            @Override
8834            public List<JournalArticle> filterFindByG_F(long groupId, long[] folderIds,
8835                    int start, int end, OrderByComparator orderByComparator)
8836                    throws SystemException {
8837                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8838                            return findByG_F(groupId, folderIds, start, end, orderByComparator);
8839                    }
8840    
8841                    StringBundler query = new StringBundler();
8842    
8843                    if (getDB().isSupportsInlineDistinct()) {
8844                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8845                    }
8846                    else {
8847                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8848                    }
8849    
8850                    boolean conjunctionable = false;
8851    
8852                    if (conjunctionable) {
8853                            query.append(WHERE_AND);
8854                    }
8855    
8856                    query.append(_FINDER_COLUMN_G_F_GROUPID_5);
8857    
8858                    conjunctionable = true;
8859    
8860                    if ((folderIds == null) || (folderIds.length > 0)) {
8861                            if (conjunctionable) {
8862                                    query.append(WHERE_AND);
8863                            }
8864    
8865                            query.append(StringPool.OPEN_PARENTHESIS);
8866    
8867                            for (int i = 0; i < folderIds.length; i++) {
8868                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
8869    
8870                                    if ((i + 1) < folderIds.length) {
8871                                            query.append(WHERE_OR);
8872                                    }
8873                            }
8874    
8875                            query.append(StringPool.CLOSE_PARENTHESIS);
8876    
8877                            conjunctionable = true;
8878                    }
8879    
8880                    if (!getDB().isSupportsInlineDistinct()) {
8881                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8882                    }
8883    
8884                    if (orderByComparator != null) {
8885                            if (getDB().isSupportsInlineDistinct()) {
8886                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8887                                            orderByComparator, true);
8888                            }
8889                            else {
8890                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8891                                            orderByComparator, true);
8892                            }
8893                    }
8894                    else {
8895                            if (getDB().isSupportsInlineDistinct()) {
8896                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8897                            }
8898                            else {
8899                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8900                            }
8901                    }
8902    
8903                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8904                                    JournalArticle.class.getName(),
8905                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8906    
8907                    Session session = null;
8908    
8909                    try {
8910                            session = openSession();
8911    
8912                            SQLQuery q = session.createSQLQuery(sql);
8913    
8914                            if (getDB().isSupportsInlineDistinct()) {
8915                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8916                            }
8917                            else {
8918                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8919                            }
8920    
8921                            QueryPos qPos = QueryPos.getInstance(q);
8922    
8923                            qPos.add(groupId);
8924    
8925                            if (folderIds != null) {
8926                                    qPos.add(folderIds);
8927                            }
8928    
8929                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
8930                                    end);
8931                    }
8932                    catch (Exception e) {
8933                            throw processException(e);
8934                    }
8935                    finally {
8936                            closeSession(session);
8937                    }
8938            }
8939    
8940            /**
8941             * Returns all the journal articles where groupId = &#63; and folderId = any &#63;.
8942             *
8943             * <p>
8944             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8945             * </p>
8946             *
8947             * @param groupId the group ID
8948             * @param folderIds the folder IDs
8949             * @return the matching journal articles
8950             * @throws SystemException if a system exception occurred
8951             */
8952            @Override
8953            public List<JournalArticle> findByG_F(long groupId, long[] folderIds)
8954                    throws SystemException {
8955                    return findByG_F(groupId, folderIds, QueryUtil.ALL_POS,
8956                            QueryUtil.ALL_POS, null);
8957            }
8958    
8959            /**
8960             * Returns a range of all the journal articles where groupId = &#63; and folderId = any &#63;.
8961             *
8962             * <p>
8963             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8964             * </p>
8965             *
8966             * @param groupId the group ID
8967             * @param folderIds the folder IDs
8968             * @param start the lower bound of the range of journal articles
8969             * @param end the upper bound of the range of journal articles (not inclusive)
8970             * @return the range of matching journal articles
8971             * @throws SystemException if a system exception occurred
8972             */
8973            @Override
8974            public List<JournalArticle> findByG_F(long groupId, long[] folderIds,
8975                    int start, int end) throws SystemException {
8976                    return findByG_F(groupId, folderIds, start, end, null);
8977            }
8978    
8979            /**
8980             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = any &#63;.
8981             *
8982             * <p>
8983             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8984             * </p>
8985             *
8986             * @param groupId the group ID
8987             * @param folderIds the folder IDs
8988             * @param start the lower bound of the range of journal articles
8989             * @param end the upper bound of the range of journal articles (not inclusive)
8990             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8991             * @return the ordered range of matching journal articles
8992             * @throws SystemException if a system exception occurred
8993             */
8994            @Override
8995            public List<JournalArticle> findByG_F(long groupId, long[] folderIds,
8996                    int start, int end, OrderByComparator orderByComparator)
8997                    throws SystemException {
8998                    if ((folderIds != null) && (folderIds.length == 1)) {
8999                            return findByG_F(groupId, folderIds[0], start, end,
9000                                    orderByComparator);
9001                    }
9002    
9003                    boolean pagination = true;
9004                    Object[] finderArgs = null;
9005    
9006                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9007                                    (orderByComparator == null)) {
9008                            pagination = false;
9009                            finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
9010                    }
9011                    else {
9012                            finderArgs = new Object[] {
9013                                            groupId, StringUtil.merge(folderIds),
9014                                            
9015                                            start, end, orderByComparator
9016                                    };
9017                    }
9018    
9019                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
9020                                    finderArgs, this);
9021    
9022                    if ((list != null) && !list.isEmpty()) {
9023                            for (JournalArticle journalArticle : list) {
9024                                    if ((groupId != journalArticle.getGroupId()) ||
9025                                                    !ArrayUtil.contains(folderIds,
9026                                                            journalArticle.getFolderId())) {
9027                                            list = null;
9028    
9029                                            break;
9030                                    }
9031                            }
9032                    }
9033    
9034                    if (list == null) {
9035                            StringBundler query = new StringBundler();
9036    
9037                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9038    
9039                            boolean conjunctionable = false;
9040    
9041                            if (conjunctionable) {
9042                                    query.append(WHERE_AND);
9043                            }
9044    
9045                            query.append(_FINDER_COLUMN_G_F_GROUPID_5);
9046    
9047                            conjunctionable = true;
9048    
9049                            if ((folderIds == null) || (folderIds.length > 0)) {
9050                                    if (conjunctionable) {
9051                                            query.append(WHERE_AND);
9052                                    }
9053    
9054                                    query.append(StringPool.OPEN_PARENTHESIS);
9055    
9056                                    for (int i = 0; i < folderIds.length; i++) {
9057                                            query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
9058    
9059                                            if ((i + 1) < folderIds.length) {
9060                                                    query.append(WHERE_OR);
9061                                            }
9062                                    }
9063    
9064                                    query.append(StringPool.CLOSE_PARENTHESIS);
9065    
9066                                    conjunctionable = true;
9067                            }
9068    
9069                            if (orderByComparator != null) {
9070                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9071                                            orderByComparator);
9072                            }
9073                            else
9074                             if (pagination) {
9075                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9076                            }
9077    
9078                            String sql = query.toString();
9079    
9080                            Session session = null;
9081    
9082                            try {
9083                                    session = openSession();
9084    
9085                                    Query q = session.createQuery(sql);
9086    
9087                                    QueryPos qPos = QueryPos.getInstance(q);
9088    
9089                                    qPos.add(groupId);
9090    
9091                                    if (folderIds != null) {
9092                                            qPos.add(folderIds);
9093                                    }
9094    
9095                                    if (!pagination) {
9096                                            list = (List<JournalArticle>)QueryUtil.list(q,
9097                                                            getDialect(), start, end, false);
9098    
9099                                            Collections.sort(list);
9100    
9101                                            list = new UnmodifiableList<JournalArticle>(list);
9102                                    }
9103                                    else {
9104                                            list = (List<JournalArticle>)QueryUtil.list(q,
9105                                                            getDialect(), start, end);
9106                                    }
9107    
9108                                    cacheResult(list);
9109    
9110                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
9111                                            finderArgs, list);
9112                            }
9113                            catch (Exception e) {
9114                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
9115                                            finderArgs);
9116    
9117                                    throw processException(e);
9118                            }
9119                            finally {
9120                                    closeSession(session);
9121                            }
9122                    }
9123    
9124                    return list;
9125            }
9126    
9127            /**
9128             * Removes all the journal articles where groupId = &#63; and folderId = &#63; from the database.
9129             *
9130             * @param groupId the group ID
9131             * @param folderId the folder ID
9132             * @throws SystemException if a system exception occurred
9133             */
9134            @Override
9135            public void removeByG_F(long groupId, long folderId)
9136                    throws SystemException {
9137                    for (JournalArticle journalArticle : findByG_F(groupId, folderId,
9138                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
9139                            remove(journalArticle);
9140                    }
9141            }
9142    
9143            /**
9144             * Returns the number of journal articles where groupId = &#63; and folderId = &#63;.
9145             *
9146             * @param groupId the group ID
9147             * @param folderId the folder ID
9148             * @return the number of matching journal articles
9149             * @throws SystemException if a system exception occurred
9150             */
9151            @Override
9152            public int countByG_F(long groupId, long folderId)
9153                    throws SystemException {
9154                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F;
9155    
9156                    Object[] finderArgs = new Object[] { groupId, folderId };
9157    
9158                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
9159                                    this);
9160    
9161                    if (count == null) {
9162                            StringBundler query = new StringBundler(3);
9163    
9164                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
9165    
9166                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
9167    
9168                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
9169    
9170                            String sql = query.toString();
9171    
9172                            Session session = null;
9173    
9174                            try {
9175                                    session = openSession();
9176    
9177                                    Query q = session.createQuery(sql);
9178    
9179                                    QueryPos qPos = QueryPos.getInstance(q);
9180    
9181                                    qPos.add(groupId);
9182    
9183                                    qPos.add(folderId);
9184    
9185                                    count = (Long)q.uniqueResult();
9186    
9187                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
9188                            }
9189                            catch (Exception e) {
9190                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9191    
9192                                    throw processException(e);
9193                            }
9194                            finally {
9195                                    closeSession(session);
9196                            }
9197                    }
9198    
9199                    return count.intValue();
9200            }
9201    
9202            /**
9203             * Returns the number of journal articles where groupId = &#63; and folderId = any &#63;.
9204             *
9205             * @param groupId the group ID
9206             * @param folderIds the folder IDs
9207             * @return the number of matching journal articles
9208             * @throws SystemException if a system exception occurred
9209             */
9210            @Override
9211            public int countByG_F(long groupId, long[] folderIds)
9212                    throws SystemException {
9213                    Object[] finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
9214    
9215                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
9216                                    finderArgs, this);
9217    
9218                    if (count == null) {
9219                            StringBundler query = new StringBundler();
9220    
9221                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
9222    
9223                            boolean conjunctionable = false;
9224    
9225                            if (conjunctionable) {
9226                                    query.append(WHERE_AND);
9227                            }
9228    
9229                            query.append(_FINDER_COLUMN_G_F_GROUPID_5);
9230    
9231                            conjunctionable = true;
9232    
9233                            if ((folderIds == null) || (folderIds.length > 0)) {
9234                                    if (conjunctionable) {
9235                                            query.append(WHERE_AND);
9236                                    }
9237    
9238                                    query.append(StringPool.OPEN_PARENTHESIS);
9239    
9240                                    for (int i = 0; i < folderIds.length; i++) {
9241                                            query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
9242    
9243                                            if ((i + 1) < folderIds.length) {
9244                                                    query.append(WHERE_OR);
9245                                            }
9246                                    }
9247    
9248                                    query.append(StringPool.CLOSE_PARENTHESIS);
9249    
9250                                    conjunctionable = true;
9251                            }
9252    
9253                            String sql = query.toString();
9254    
9255                            Session session = null;
9256    
9257                            try {
9258                                    session = openSession();
9259    
9260                                    Query q = session.createQuery(sql);
9261    
9262                                    QueryPos qPos = QueryPos.getInstance(q);
9263    
9264                                    qPos.add(groupId);
9265    
9266                                    if (folderIds != null) {
9267                                            qPos.add(folderIds);
9268                                    }
9269    
9270                                    count = (Long)q.uniqueResult();
9271    
9272                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
9273                                            finderArgs, count);
9274                            }
9275                            catch (Exception e) {
9276                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
9277                                            finderArgs);
9278    
9279                                    throw processException(e);
9280                            }
9281                            finally {
9282                                    closeSession(session);
9283                            }
9284                    }
9285    
9286                    return count.intValue();
9287            }
9288    
9289            /**
9290             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
9291             *
9292             * @param groupId the group ID
9293             * @param folderId the folder ID
9294             * @return the number of matching journal articles that the user has permission to view
9295             * @throws SystemException if a system exception occurred
9296             */
9297            @Override
9298            public int filterCountByG_F(long groupId, long folderId)
9299                    throws SystemException {
9300                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9301                            return countByG_F(groupId, folderId);
9302                    }
9303    
9304                    StringBundler query = new StringBundler(3);
9305    
9306                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
9307    
9308                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
9309    
9310                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
9311    
9312                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9313                                    JournalArticle.class.getName(),
9314                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9315    
9316                    Session session = null;
9317    
9318                    try {
9319                            session = openSession();
9320    
9321                            SQLQuery q = session.createSQLQuery(sql);
9322    
9323                            q.addScalar(COUNT_COLUMN_NAME,
9324                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9325    
9326                            QueryPos qPos = QueryPos.getInstance(q);
9327    
9328                            qPos.add(groupId);
9329    
9330                            qPos.add(folderId);
9331    
9332                            Long count = (Long)q.uniqueResult();
9333    
9334                            return count.intValue();
9335                    }
9336                    catch (Exception e) {
9337                            throw processException(e);
9338                    }
9339                    finally {
9340                            closeSession(session);
9341                    }
9342            }
9343    
9344            /**
9345             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
9346             *
9347             * @param groupId the group ID
9348             * @param folderIds the folder IDs
9349             * @return the number of matching journal articles that the user has permission to view
9350             * @throws SystemException if a system exception occurred
9351             */
9352            @Override
9353            public int filterCountByG_F(long groupId, long[] folderIds)
9354                    throws SystemException {
9355                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9356                            return countByG_F(groupId, folderIds);
9357                    }
9358    
9359                    StringBundler query = new StringBundler();
9360    
9361                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
9362    
9363                    boolean conjunctionable = false;
9364    
9365                    if (conjunctionable) {
9366                            query.append(WHERE_AND);
9367                    }
9368    
9369                    query.append(_FINDER_COLUMN_G_F_GROUPID_5);
9370    
9371                    conjunctionable = true;
9372    
9373                    if ((folderIds == null) || (folderIds.length > 0)) {
9374                            if (conjunctionable) {
9375                                    query.append(WHERE_AND);
9376                            }
9377    
9378                            query.append(StringPool.OPEN_PARENTHESIS);
9379    
9380                            for (int i = 0; i < folderIds.length; i++) {
9381                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
9382    
9383                                    if ((i + 1) < folderIds.length) {
9384                                            query.append(WHERE_OR);
9385                                    }
9386                            }
9387    
9388                            query.append(StringPool.CLOSE_PARENTHESIS);
9389    
9390                            conjunctionable = true;
9391                    }
9392    
9393                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9394                                    JournalArticle.class.getName(),
9395                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9396    
9397                    Session session = null;
9398    
9399                    try {
9400                            session = openSession();
9401    
9402                            SQLQuery q = session.createSQLQuery(sql);
9403    
9404                            q.addScalar(COUNT_COLUMN_NAME,
9405                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9406    
9407                            QueryPos qPos = QueryPos.getInstance(q);
9408    
9409                            qPos.add(groupId);
9410    
9411                            if (folderIds != null) {
9412                                    qPos.add(folderIds);
9413                            }
9414    
9415                            Long count = (Long)q.uniqueResult();
9416    
9417                            return count.intValue();
9418                    }
9419                    catch (Exception e) {
9420                            throw processException(e);
9421                    }
9422                    finally {
9423                            closeSession(session);
9424                    }
9425            }
9426    
9427            private static final String _FINDER_COLUMN_G_F_GROUPID_2 = "journalArticle.groupId = ? AND ";
9428            private static final String _FINDER_COLUMN_G_F_GROUPID_5 = "(" +
9429                    removeConjunction(_FINDER_COLUMN_G_F_GROUPID_2) + ")";
9430            private static final String _FINDER_COLUMN_G_F_FOLDERID_2 = "journalArticle.folderId = ?";
9431            private static final String _FINDER_COLUMN_G_F_FOLDERID_5 = "(" +
9432                    removeConjunction(_FINDER_COLUMN_G_F_FOLDERID_2) + ")";
9433            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
9434                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
9435                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
9436                            "findByG_A",
9437                            new String[] {
9438                                    Long.class.getName(), String.class.getName(),
9439                                    
9440                            Integer.class.getName(), Integer.class.getName(),
9441                                    OrderByComparator.class.getName()
9442                            });
9443            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
9444                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
9445                            JournalArticleImpl.class,
9446                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A",
9447                            new String[] { Long.class.getName(), String.class.getName() },
9448                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
9449                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
9450                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
9451            public static final FinderPath FINDER_PATH_COUNT_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
9452                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
9453                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A",
9454                            new String[] { Long.class.getName(), String.class.getName() });
9455    
9456            /**
9457             * Returns all the journal articles where groupId = &#63; and articleId = &#63;.
9458             *
9459             * @param groupId the group ID
9460             * @param articleId the article ID
9461             * @return the matching journal articles
9462             * @throws SystemException if a system exception occurred
9463             */
9464            @Override
9465            public List<JournalArticle> findByG_A(long groupId, String articleId)
9466                    throws SystemException {
9467                    return findByG_A(groupId, articleId, QueryUtil.ALL_POS,
9468                            QueryUtil.ALL_POS, null);
9469            }
9470    
9471            /**
9472             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63;.
9473             *
9474             * <p>
9475             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9476             * </p>
9477             *
9478             * @param groupId the group ID
9479             * @param articleId the article ID
9480             * @param start the lower bound of the range of journal articles
9481             * @param end the upper bound of the range of journal articles (not inclusive)
9482             * @return the range of matching journal articles
9483             * @throws SystemException if a system exception occurred
9484             */
9485            @Override
9486            public List<JournalArticle> findByG_A(long groupId, String articleId,
9487                    int start, int end) throws SystemException {
9488                    return findByG_A(groupId, articleId, start, end, null);
9489            }
9490    
9491            /**
9492             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63;.
9493             *
9494             * <p>
9495             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9496             * </p>
9497             *
9498             * @param groupId the group ID
9499             * @param articleId the article ID
9500             * @param start the lower bound of the range of journal articles
9501             * @param end the upper bound of the range of journal articles (not inclusive)
9502             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9503             * @return the ordered range of matching journal articles
9504             * @throws SystemException if a system exception occurred
9505             */
9506            @Override
9507            public List<JournalArticle> findByG_A(long groupId, String articleId,
9508                    int start, int end, OrderByComparator orderByComparator)
9509                    throws SystemException {
9510                    boolean pagination = true;
9511                    FinderPath finderPath = null;
9512                    Object[] finderArgs = null;
9513    
9514                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9515                                    (orderByComparator == null)) {
9516                            pagination = false;
9517                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A;
9518                            finderArgs = new Object[] { groupId, articleId };
9519                    }
9520                    else {
9521                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A;
9522                            finderArgs = new Object[] {
9523                                            groupId, articleId,
9524                                            
9525                                            start, end, orderByComparator
9526                                    };
9527                    }
9528    
9529                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
9530                                    finderArgs, this);
9531    
9532                    if ((list != null) && !list.isEmpty()) {
9533                            for (JournalArticle journalArticle : list) {
9534                                    if ((groupId != journalArticle.getGroupId()) ||
9535                                                    !Validator.equals(articleId,
9536                                                            journalArticle.getArticleId())) {
9537                                            list = null;
9538    
9539                                            break;
9540                                    }
9541                            }
9542                    }
9543    
9544                    if (list == null) {
9545                            StringBundler query = null;
9546    
9547                            if (orderByComparator != null) {
9548                                    query = new StringBundler(4 +
9549                                                    (orderByComparator.getOrderByFields().length * 3));
9550                            }
9551                            else {
9552                                    query = new StringBundler(4);
9553                            }
9554    
9555                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9556    
9557                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
9558    
9559                            boolean bindArticleId = false;
9560    
9561                            if (articleId == null) {
9562                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
9563                            }
9564                            else if (articleId.equals(StringPool.BLANK)) {
9565                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
9566                            }
9567                            else {
9568                                    bindArticleId = true;
9569    
9570                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
9571                            }
9572    
9573                            if (orderByComparator != null) {
9574                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9575                                            orderByComparator);
9576                            }
9577                            else
9578                             if (pagination) {
9579                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9580                            }
9581    
9582                            String sql = query.toString();
9583    
9584                            Session session = null;
9585    
9586                            try {
9587                                    session = openSession();
9588    
9589                                    Query q = session.createQuery(sql);
9590    
9591                                    QueryPos qPos = QueryPos.getInstance(q);
9592    
9593                                    qPos.add(groupId);
9594    
9595                                    if (bindArticleId) {
9596                                            qPos.add(articleId);
9597                                    }
9598    
9599                                    if (!pagination) {
9600                                            list = (List<JournalArticle>)QueryUtil.list(q,
9601                                                            getDialect(), start, end, false);
9602    
9603                                            Collections.sort(list);
9604    
9605                                            list = new UnmodifiableList<JournalArticle>(list);
9606                                    }
9607                                    else {
9608                                            list = (List<JournalArticle>)QueryUtil.list(q,
9609                                                            getDialect(), start, end);
9610                                    }
9611    
9612                                    cacheResult(list);
9613    
9614                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
9615                            }
9616                            catch (Exception e) {
9617                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9618    
9619                                    throw processException(e);
9620                            }
9621                            finally {
9622                                    closeSession(session);
9623                            }
9624                    }
9625    
9626                    return list;
9627            }
9628    
9629            /**
9630             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63;.
9631             *
9632             * @param groupId the group ID
9633             * @param articleId the article ID
9634             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9635             * @return the first matching journal article
9636             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9637             * @throws SystemException if a system exception occurred
9638             */
9639            @Override
9640            public JournalArticle findByG_A_First(long groupId, String articleId,
9641                    OrderByComparator orderByComparator)
9642                    throws NoSuchArticleException, SystemException {
9643                    JournalArticle journalArticle = fetchByG_A_First(groupId, articleId,
9644                                    orderByComparator);
9645    
9646                    if (journalArticle != null) {
9647                            return journalArticle;
9648                    }
9649    
9650                    StringBundler msg = new StringBundler(6);
9651    
9652                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9653    
9654                    msg.append("groupId=");
9655                    msg.append(groupId);
9656    
9657                    msg.append(", articleId=");
9658                    msg.append(articleId);
9659    
9660                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9661    
9662                    throw new NoSuchArticleException(msg.toString());
9663            }
9664    
9665            /**
9666             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63;.
9667             *
9668             * @param groupId the group ID
9669             * @param articleId the article ID
9670             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9671             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
9672             * @throws SystemException if a system exception occurred
9673             */
9674            @Override
9675            public JournalArticle fetchByG_A_First(long groupId, String articleId,
9676                    OrderByComparator orderByComparator) throws SystemException {
9677                    List<JournalArticle> list = findByG_A(groupId, articleId, 0, 1,
9678                                    orderByComparator);
9679    
9680                    if (!list.isEmpty()) {
9681                            return list.get(0);
9682                    }
9683    
9684                    return null;
9685            }
9686    
9687            /**
9688             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63;.
9689             *
9690             * @param groupId the group ID
9691             * @param articleId the article ID
9692             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9693             * @return the last matching journal article
9694             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9695             * @throws SystemException if a system exception occurred
9696             */
9697            @Override
9698            public JournalArticle findByG_A_Last(long groupId, String articleId,
9699                    OrderByComparator orderByComparator)
9700                    throws NoSuchArticleException, SystemException {
9701                    JournalArticle journalArticle = fetchByG_A_Last(groupId, articleId,
9702                                    orderByComparator);
9703    
9704                    if (journalArticle != null) {
9705                            return journalArticle;
9706                    }
9707    
9708                    StringBundler msg = new StringBundler(6);
9709    
9710                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9711    
9712                    msg.append("groupId=");
9713                    msg.append(groupId);
9714    
9715                    msg.append(", articleId=");
9716                    msg.append(articleId);
9717    
9718                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9719    
9720                    throw new NoSuchArticleException(msg.toString());
9721            }
9722    
9723            /**
9724             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63;.
9725             *
9726             * @param groupId the group ID
9727             * @param articleId the article ID
9728             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9729             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
9730             * @throws SystemException if a system exception occurred
9731             */
9732            @Override
9733            public JournalArticle fetchByG_A_Last(long groupId, String articleId,
9734                    OrderByComparator orderByComparator) throws SystemException {
9735                    int count = countByG_A(groupId, articleId);
9736    
9737                    if (count == 0) {
9738                            return null;
9739                    }
9740    
9741                    List<JournalArticle> list = findByG_A(groupId, articleId, count - 1,
9742                                    count, orderByComparator);
9743    
9744                    if (!list.isEmpty()) {
9745                            return list.get(0);
9746                    }
9747    
9748                    return null;
9749            }
9750    
9751            /**
9752             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63;.
9753             *
9754             * @param id the primary key of the current journal article
9755             * @param groupId the group ID
9756             * @param articleId the article ID
9757             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9758             * @return the previous, current, and next journal article
9759             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
9760             * @throws SystemException if a system exception occurred
9761             */
9762            @Override
9763            public JournalArticle[] findByG_A_PrevAndNext(long id, long groupId,
9764                    String articleId, OrderByComparator orderByComparator)
9765                    throws NoSuchArticleException, SystemException {
9766                    JournalArticle journalArticle = findByPrimaryKey(id);
9767    
9768                    Session session = null;
9769    
9770                    try {
9771                            session = openSession();
9772    
9773                            JournalArticle[] array = new JournalArticleImpl[3];
9774    
9775                            array[0] = getByG_A_PrevAndNext(session, journalArticle, groupId,
9776                                            articleId, orderByComparator, true);
9777    
9778                            array[1] = journalArticle;
9779    
9780                            array[2] = getByG_A_PrevAndNext(session, journalArticle, groupId,
9781                                            articleId, orderByComparator, false);
9782    
9783                            return array;
9784                    }
9785                    catch (Exception e) {
9786                            throw processException(e);
9787                    }
9788                    finally {
9789                            closeSession(session);
9790                    }
9791            }
9792    
9793            protected JournalArticle getByG_A_PrevAndNext(Session session,
9794                    JournalArticle journalArticle, long groupId, String articleId,
9795                    OrderByComparator orderByComparator, boolean previous) {
9796                    StringBundler query = null;
9797    
9798                    if (orderByComparator != null) {
9799                            query = new StringBundler(6 +
9800                                            (orderByComparator.getOrderByFields().length * 6));
9801                    }
9802                    else {
9803                            query = new StringBundler(3);
9804                    }
9805    
9806                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9807    
9808                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
9809    
9810                    boolean bindArticleId = false;
9811    
9812                    if (articleId == null) {
9813                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
9814                    }
9815                    else if (articleId.equals(StringPool.BLANK)) {
9816                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
9817                    }
9818                    else {
9819                            bindArticleId = true;
9820    
9821                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
9822                    }
9823    
9824                    if (orderByComparator != null) {
9825                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9826    
9827                            if (orderByConditionFields.length > 0) {
9828                                    query.append(WHERE_AND);
9829                            }
9830    
9831                            for (int i = 0; i < orderByConditionFields.length; i++) {
9832                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9833                                    query.append(orderByConditionFields[i]);
9834    
9835                                    if ((i + 1) < orderByConditionFields.length) {
9836                                            if (orderByComparator.isAscending() ^ previous) {
9837                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9838                                            }
9839                                            else {
9840                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9841                                            }
9842                                    }
9843                                    else {
9844                                            if (orderByComparator.isAscending() ^ previous) {
9845                                                    query.append(WHERE_GREATER_THAN);
9846                                            }
9847                                            else {
9848                                                    query.append(WHERE_LESSER_THAN);
9849                                            }
9850                                    }
9851                            }
9852    
9853                            query.append(ORDER_BY_CLAUSE);
9854    
9855                            String[] orderByFields = orderByComparator.getOrderByFields();
9856    
9857                            for (int i = 0; i < orderByFields.length; i++) {
9858                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9859                                    query.append(orderByFields[i]);
9860    
9861                                    if ((i + 1) < orderByFields.length) {
9862                                            if (orderByComparator.isAscending() ^ previous) {
9863                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9864                                            }
9865                                            else {
9866                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9867                                            }
9868                                    }
9869                                    else {
9870                                            if (orderByComparator.isAscending() ^ previous) {
9871                                                    query.append(ORDER_BY_ASC);
9872                                            }
9873                                            else {
9874                                                    query.append(ORDER_BY_DESC);
9875                                            }
9876                                    }
9877                            }
9878                    }
9879                    else {
9880                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9881                    }
9882    
9883                    String sql = query.toString();
9884    
9885                    Query q = session.createQuery(sql);
9886    
9887                    q.setFirstResult(0);
9888                    q.setMaxResults(2);
9889    
9890                    QueryPos qPos = QueryPos.getInstance(q);
9891    
9892                    qPos.add(groupId);
9893    
9894                    if (bindArticleId) {
9895                            qPos.add(articleId);
9896                    }
9897    
9898                    if (orderByComparator != null) {
9899                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
9900    
9901                            for (Object value : values) {
9902                                    qPos.add(value);
9903                            }
9904                    }
9905    
9906                    List<JournalArticle> list = q.list();
9907    
9908                    if (list.size() == 2) {
9909                            return list.get(1);
9910                    }
9911                    else {
9912                            return null;
9913                    }
9914            }
9915    
9916            /**
9917             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
9918             *
9919             * @param groupId the group ID
9920             * @param articleId the article ID
9921             * @return the matching journal articles that the user has permission to view
9922             * @throws SystemException if a system exception occurred
9923             */
9924            @Override
9925            public List<JournalArticle> filterFindByG_A(long groupId, String articleId)
9926                    throws SystemException {
9927                    return filterFindByG_A(groupId, articleId, QueryUtil.ALL_POS,
9928                            QueryUtil.ALL_POS, null);
9929            }
9930    
9931            /**
9932             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
9933             *
9934             * <p>
9935             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9936             * </p>
9937             *
9938             * @param groupId the group ID
9939             * @param articleId the article ID
9940             * @param start the lower bound of the range of journal articles
9941             * @param end the upper bound of the range of journal articles (not inclusive)
9942             * @return the range of matching journal articles that the user has permission to view
9943             * @throws SystemException if a system exception occurred
9944             */
9945            @Override
9946            public List<JournalArticle> filterFindByG_A(long groupId, String articleId,
9947                    int start, int end) throws SystemException {
9948                    return filterFindByG_A(groupId, articleId, start, end, null);
9949            }
9950    
9951            /**
9952             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and articleId = &#63;.
9953             *
9954             * <p>
9955             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9956             * </p>
9957             *
9958             * @param groupId the group ID
9959             * @param articleId the article ID
9960             * @param start the lower bound of the range of journal articles
9961             * @param end the upper bound of the range of journal articles (not inclusive)
9962             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9963             * @return the ordered range of matching journal articles that the user has permission to view
9964             * @throws SystemException if a system exception occurred
9965             */
9966            @Override
9967            public List<JournalArticle> filterFindByG_A(long groupId, String articleId,
9968                    int start, int end, OrderByComparator orderByComparator)
9969                    throws SystemException {
9970                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9971                            return findByG_A(groupId, articleId, start, end, orderByComparator);
9972                    }
9973    
9974                    StringBundler query = null;
9975    
9976                    if (orderByComparator != null) {
9977                            query = new StringBundler(4 +
9978                                            (orderByComparator.getOrderByFields().length * 3));
9979                    }
9980                    else {
9981                            query = new StringBundler(4);
9982                    }
9983    
9984                    if (getDB().isSupportsInlineDistinct()) {
9985                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
9986                    }
9987                    else {
9988                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
9989                    }
9990    
9991                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
9992    
9993                    boolean bindArticleId = false;
9994    
9995                    if (articleId == null) {
9996                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
9997                    }
9998                    else if (articleId.equals(StringPool.BLANK)) {
9999                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
10000                    }
10001                    else {
10002                            bindArticleId = true;
10003    
10004                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
10005                    }
10006    
10007                    if (!getDB().isSupportsInlineDistinct()) {
10008                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
10009                    }
10010    
10011                    if (orderByComparator != null) {
10012                            if (getDB().isSupportsInlineDistinct()) {
10013                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10014                                            orderByComparator, true);
10015                            }
10016                            else {
10017                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10018                                            orderByComparator, true);
10019                            }
10020                    }
10021                    else {
10022                            if (getDB().isSupportsInlineDistinct()) {
10023                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10024                            }
10025                            else {
10026                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
10027                            }
10028                    }
10029    
10030                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10031                                    JournalArticle.class.getName(),
10032                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10033    
10034                    Session session = null;
10035    
10036                    try {
10037                            session = openSession();
10038    
10039                            SQLQuery q = session.createSQLQuery(sql);
10040    
10041                            if (getDB().isSupportsInlineDistinct()) {
10042                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
10043                            }
10044                            else {
10045                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
10046                            }
10047    
10048                            QueryPos qPos = QueryPos.getInstance(q);
10049    
10050                            qPos.add(groupId);
10051    
10052                            if (bindArticleId) {
10053                                    qPos.add(articleId);
10054                            }
10055    
10056                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
10057                                    end);
10058                    }
10059                    catch (Exception e) {
10060                            throw processException(e);
10061                    }
10062                    finally {
10063                            closeSession(session);
10064                    }
10065            }
10066    
10067            /**
10068             * 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;.
10069             *
10070             * @param id the primary key of the current journal article
10071             * @param groupId the group ID
10072             * @param articleId the article ID
10073             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10074             * @return the previous, current, and next journal article
10075             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
10076             * @throws SystemException if a system exception occurred
10077             */
10078            @Override
10079            public JournalArticle[] filterFindByG_A_PrevAndNext(long id, long groupId,
10080                    String articleId, OrderByComparator orderByComparator)
10081                    throws NoSuchArticleException, SystemException {
10082                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10083                            return findByG_A_PrevAndNext(id, groupId, articleId,
10084                                    orderByComparator);
10085                    }
10086    
10087                    JournalArticle journalArticle = findByPrimaryKey(id);
10088    
10089                    Session session = null;
10090    
10091                    try {
10092                            session = openSession();
10093    
10094                            JournalArticle[] array = new JournalArticleImpl[3];
10095    
10096                            array[0] = filterGetByG_A_PrevAndNext(session, journalArticle,
10097                                            groupId, articleId, orderByComparator, true);
10098    
10099                            array[1] = journalArticle;
10100    
10101                            array[2] = filterGetByG_A_PrevAndNext(session, journalArticle,
10102                                            groupId, articleId, orderByComparator, false);
10103    
10104                            return array;
10105                    }
10106                    catch (Exception e) {
10107                            throw processException(e);
10108                    }
10109                    finally {
10110                            closeSession(session);
10111                    }
10112            }
10113    
10114            protected JournalArticle filterGetByG_A_PrevAndNext(Session session,
10115                    JournalArticle journalArticle, long groupId, String articleId,
10116                    OrderByComparator orderByComparator, boolean previous) {
10117                    StringBundler query = null;
10118    
10119                    if (orderByComparator != null) {
10120                            query = new StringBundler(6 +
10121                                            (orderByComparator.getOrderByFields().length * 6));
10122                    }
10123                    else {
10124                            query = new StringBundler(3);
10125                    }
10126    
10127                    if (getDB().isSupportsInlineDistinct()) {
10128                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
10129                    }
10130                    else {
10131                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
10132                    }
10133    
10134                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
10135    
10136                    boolean bindArticleId = false;
10137    
10138                    if (articleId == null) {
10139                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
10140                    }
10141                    else if (articleId.equals(StringPool.BLANK)) {
10142                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
10143                    }
10144                    else {
10145                            bindArticleId = true;
10146    
10147                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
10148                    }
10149    
10150                    if (!getDB().isSupportsInlineDistinct()) {
10151                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
10152                    }
10153    
10154                    if (orderByComparator != null) {
10155                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10156    
10157                            if (orderByConditionFields.length > 0) {
10158                                    query.append(WHERE_AND);
10159                            }
10160    
10161                            for (int i = 0; i < orderByConditionFields.length; i++) {
10162                                    if (getDB().isSupportsInlineDistinct()) {
10163                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10164                                    }
10165                                    else {
10166                                            query.append(_ORDER_BY_ENTITY_TABLE);
10167                                    }
10168    
10169                                    query.append(orderByConditionFields[i]);
10170    
10171                                    if ((i + 1) < orderByConditionFields.length) {
10172                                            if (orderByComparator.isAscending() ^ previous) {
10173                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10174                                            }
10175                                            else {
10176                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10177                                            }
10178                                    }
10179                                    else {
10180                                            if (orderByComparator.isAscending() ^ previous) {
10181                                                    query.append(WHERE_GREATER_THAN);
10182                                            }
10183                                            else {
10184                                                    query.append(WHERE_LESSER_THAN);
10185                                            }
10186                                    }
10187                            }
10188    
10189                            query.append(ORDER_BY_CLAUSE);
10190    
10191                            String[] orderByFields = orderByComparator.getOrderByFields();
10192    
10193                            for (int i = 0; i < orderByFields.length; i++) {
10194                                    if (getDB().isSupportsInlineDistinct()) {
10195                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10196                                    }
10197                                    else {
10198                                            query.append(_ORDER_BY_ENTITY_TABLE);
10199                                    }
10200    
10201                                    query.append(orderByFields[i]);
10202    
10203                                    if ((i + 1) < orderByFields.length) {
10204                                            if (orderByComparator.isAscending() ^ previous) {
10205                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10206                                            }
10207                                            else {
10208                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10209                                            }
10210                                    }
10211                                    else {
10212                                            if (orderByComparator.isAscending() ^ previous) {
10213                                                    query.append(ORDER_BY_ASC);
10214                                            }
10215                                            else {
10216                                                    query.append(ORDER_BY_DESC);
10217                                            }
10218                                    }
10219                            }
10220                    }
10221                    else {
10222                            if (getDB().isSupportsInlineDistinct()) {
10223                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10224                            }
10225                            else {
10226                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
10227                            }
10228                    }
10229    
10230                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10231                                    JournalArticle.class.getName(),
10232                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10233    
10234                    SQLQuery q = session.createSQLQuery(sql);
10235    
10236                    q.setFirstResult(0);
10237                    q.setMaxResults(2);
10238    
10239                    if (getDB().isSupportsInlineDistinct()) {
10240                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
10241                    }
10242                    else {
10243                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
10244                    }
10245    
10246                    QueryPos qPos = QueryPos.getInstance(q);
10247    
10248                    qPos.add(groupId);
10249    
10250                    if (bindArticleId) {
10251                            qPos.add(articleId);
10252                    }
10253    
10254                    if (orderByComparator != null) {
10255                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
10256    
10257                            for (Object value : values) {
10258                                    qPos.add(value);
10259                            }
10260                    }
10261    
10262                    List<JournalArticle> list = q.list();
10263    
10264                    if (list.size() == 2) {
10265                            return list.get(1);
10266                    }
10267                    else {
10268                            return null;
10269                    }
10270            }
10271    
10272            /**
10273             * Removes all the journal articles where groupId = &#63; and articleId = &#63; from the database.
10274             *
10275             * @param groupId the group ID
10276             * @param articleId the article ID
10277             * @throws SystemException if a system exception occurred
10278             */
10279            @Override
10280            public void removeByG_A(long groupId, String articleId)
10281                    throws SystemException {
10282                    for (JournalArticle journalArticle : findByG_A(groupId, articleId,
10283                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10284                            remove(journalArticle);
10285                    }
10286            }
10287    
10288            /**
10289             * Returns the number of journal articles where groupId = &#63; and articleId = &#63;.
10290             *
10291             * @param groupId the group ID
10292             * @param articleId the article ID
10293             * @return the number of matching journal articles
10294             * @throws SystemException if a system exception occurred
10295             */
10296            @Override
10297            public int countByG_A(long groupId, String articleId)
10298                    throws SystemException {
10299                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A;
10300    
10301                    Object[] finderArgs = new Object[] { groupId, articleId };
10302    
10303                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
10304                                    this);
10305    
10306                    if (count == null) {
10307                            StringBundler query = new StringBundler(3);
10308    
10309                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
10310    
10311                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
10312    
10313                            boolean bindArticleId = false;
10314    
10315                            if (articleId == null) {
10316                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
10317                            }
10318                            else if (articleId.equals(StringPool.BLANK)) {
10319                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
10320                            }
10321                            else {
10322                                    bindArticleId = true;
10323    
10324                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
10325                            }
10326    
10327                            String sql = query.toString();
10328    
10329                            Session session = null;
10330    
10331                            try {
10332                                    session = openSession();
10333    
10334                                    Query q = session.createQuery(sql);
10335    
10336                                    QueryPos qPos = QueryPos.getInstance(q);
10337    
10338                                    qPos.add(groupId);
10339    
10340                                    if (bindArticleId) {
10341                                            qPos.add(articleId);
10342                                    }
10343    
10344                                    count = (Long)q.uniqueResult();
10345    
10346                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
10347                            }
10348                            catch (Exception e) {
10349                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10350    
10351                                    throw processException(e);
10352                            }
10353                            finally {
10354                                    closeSession(session);
10355                            }
10356                    }
10357    
10358                    return count.intValue();
10359            }
10360    
10361            /**
10362             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
10363             *
10364             * @param groupId the group ID
10365             * @param articleId the article ID
10366             * @return the number of matching journal articles that the user has permission to view
10367             * @throws SystemException if a system exception occurred
10368             */
10369            @Override
10370            public int filterCountByG_A(long groupId, String articleId)
10371                    throws SystemException {
10372                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10373                            return countByG_A(groupId, articleId);
10374                    }
10375    
10376                    StringBundler query = new StringBundler(3);
10377    
10378                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
10379    
10380                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
10381    
10382                    boolean bindArticleId = false;
10383    
10384                    if (articleId == null) {
10385                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
10386                    }
10387                    else if (articleId.equals(StringPool.BLANK)) {
10388                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
10389                    }
10390                    else {
10391                            bindArticleId = true;
10392    
10393                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
10394                    }
10395    
10396                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10397                                    JournalArticle.class.getName(),
10398                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10399    
10400                    Session session = null;
10401    
10402                    try {
10403                            session = openSession();
10404    
10405                            SQLQuery q = session.createSQLQuery(sql);
10406    
10407                            q.addScalar(COUNT_COLUMN_NAME,
10408                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
10409    
10410                            QueryPos qPos = QueryPos.getInstance(q);
10411    
10412                            qPos.add(groupId);
10413    
10414                            if (bindArticleId) {
10415                                    qPos.add(articleId);
10416                            }
10417    
10418                            Long count = (Long)q.uniqueResult();
10419    
10420                            return count.intValue();
10421                    }
10422                    catch (Exception e) {
10423                            throw processException(e);
10424                    }
10425                    finally {
10426                            closeSession(session);
10427                    }
10428            }
10429    
10430            private static final String _FINDER_COLUMN_G_A_GROUPID_2 = "journalArticle.groupId = ? AND ";
10431            private static final String _FINDER_COLUMN_G_A_ARTICLEID_1 = "journalArticle.articleId IS NULL";
10432            private static final String _FINDER_COLUMN_G_A_ARTICLEID_2 = "journalArticle.articleId = ?";
10433            private static final String _FINDER_COLUMN_G_A_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '')";
10434            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
10435                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
10436                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
10437                            "findByG_UT",
10438                            new String[] {
10439                                    Long.class.getName(), String.class.getName(),
10440                                    
10441                            Integer.class.getName(), Integer.class.getName(),
10442                                    OrderByComparator.class.getName()
10443                            });
10444            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
10445                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
10446                            JournalArticleImpl.class,
10447                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_UT",
10448                            new String[] { Long.class.getName(), String.class.getName() },
10449                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
10450                            JournalArticleModelImpl.URLTITLE_COLUMN_BITMASK |
10451                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
10452                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
10453            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
10454                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
10455                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT",
10456                            new String[] { Long.class.getName(), String.class.getName() });
10457    
10458            /**
10459             * Returns all the journal articles where groupId = &#63; and urlTitle = &#63;.
10460             *
10461             * @param groupId the group ID
10462             * @param urlTitle the url title
10463             * @return the matching journal articles
10464             * @throws SystemException if a system exception occurred
10465             */
10466            @Override
10467            public List<JournalArticle> findByG_UT(long groupId, String urlTitle)
10468                    throws SystemException {
10469                    return findByG_UT(groupId, urlTitle, QueryUtil.ALL_POS,
10470                            QueryUtil.ALL_POS, null);
10471            }
10472    
10473            /**
10474             * Returns a range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
10475             *
10476             * <p>
10477             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10478             * </p>
10479             *
10480             * @param groupId the group ID
10481             * @param urlTitle the url title
10482             * @param start the lower bound of the range of journal articles
10483             * @param end the upper bound of the range of journal articles (not inclusive)
10484             * @return the range of matching journal articles
10485             * @throws SystemException if a system exception occurred
10486             */
10487            @Override
10488            public List<JournalArticle> findByG_UT(long groupId, String urlTitle,
10489                    int start, int end) throws SystemException {
10490                    return findByG_UT(groupId, urlTitle, start, end, null);
10491            }
10492    
10493            /**
10494             * Returns an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
10495             *
10496             * <p>
10497             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10498             * </p>
10499             *
10500             * @param groupId the group ID
10501             * @param urlTitle the url title
10502             * @param start the lower bound of the range of journal articles
10503             * @param end the upper bound of the range of journal articles (not inclusive)
10504             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10505             * @return the ordered range of matching journal articles
10506             * @throws SystemException if a system exception occurred
10507             */
10508            @Override
10509            public List<JournalArticle> findByG_UT(long groupId, String urlTitle,
10510                    int start, int end, OrderByComparator orderByComparator)
10511                    throws SystemException {
10512                    boolean pagination = true;
10513                    FinderPath finderPath = null;
10514                    Object[] finderArgs = null;
10515    
10516                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10517                                    (orderByComparator == null)) {
10518                            pagination = false;
10519                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT;
10520                            finderArgs = new Object[] { groupId, urlTitle };
10521                    }
10522                    else {
10523                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT;
10524                            finderArgs = new Object[] {
10525                                            groupId, urlTitle,
10526                                            
10527                                            start, end, orderByComparator
10528                                    };
10529                    }
10530    
10531                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
10532                                    finderArgs, this);
10533    
10534                    if ((list != null) && !list.isEmpty()) {
10535                            for (JournalArticle journalArticle : list) {
10536                                    if ((groupId != journalArticle.getGroupId()) ||
10537                                                    !Validator.equals(urlTitle, journalArticle.getUrlTitle())) {
10538                                            list = null;
10539    
10540                                            break;
10541                                    }
10542                            }
10543                    }
10544    
10545                    if (list == null) {
10546                            StringBundler query = null;
10547    
10548                            if (orderByComparator != null) {
10549                                    query = new StringBundler(4 +
10550                                                    (orderByComparator.getOrderByFields().length * 3));
10551                            }
10552                            else {
10553                                    query = new StringBundler(4);
10554                            }
10555    
10556                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10557    
10558                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
10559    
10560                            boolean bindUrlTitle = false;
10561    
10562                            if (urlTitle == null) {
10563                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
10564                            }
10565                            else if (urlTitle.equals(StringPool.BLANK)) {
10566                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
10567                            }
10568                            else {
10569                                    bindUrlTitle = true;
10570    
10571                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
10572                            }
10573    
10574                            if (orderByComparator != null) {
10575                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10576                                            orderByComparator);
10577                            }
10578                            else
10579                             if (pagination) {
10580                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10581                            }
10582    
10583                            String sql = query.toString();
10584    
10585                            Session session = null;
10586    
10587                            try {
10588                                    session = openSession();
10589    
10590                                    Query q = session.createQuery(sql);
10591    
10592                                    QueryPos qPos = QueryPos.getInstance(q);
10593    
10594                                    qPos.add(groupId);
10595    
10596                                    if (bindUrlTitle) {
10597                                            qPos.add(urlTitle);
10598                                    }
10599    
10600                                    if (!pagination) {
10601                                            list = (List<JournalArticle>)QueryUtil.list(q,
10602                                                            getDialect(), start, end, false);
10603    
10604                                            Collections.sort(list);
10605    
10606                                            list = new UnmodifiableList<JournalArticle>(list);
10607                                    }
10608                                    else {
10609                                            list = (List<JournalArticle>)QueryUtil.list(q,
10610                                                            getDialect(), start, end);
10611                                    }
10612    
10613                                    cacheResult(list);
10614    
10615                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
10616                            }
10617                            catch (Exception e) {
10618                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10619    
10620                                    throw processException(e);
10621                            }
10622                            finally {
10623                                    closeSession(session);
10624                            }
10625                    }
10626    
10627                    return list;
10628            }
10629    
10630            /**
10631             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
10632             *
10633             * @param groupId the group ID
10634             * @param urlTitle the url title
10635             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10636             * @return the first matching journal article
10637             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10638             * @throws SystemException if a system exception occurred
10639             */
10640            @Override
10641            public JournalArticle findByG_UT_First(long groupId, String urlTitle,
10642                    OrderByComparator orderByComparator)
10643                    throws NoSuchArticleException, SystemException {
10644                    JournalArticle journalArticle = fetchByG_UT_First(groupId, urlTitle,
10645                                    orderByComparator);
10646    
10647                    if (journalArticle != null) {
10648                            return journalArticle;
10649                    }
10650    
10651                    StringBundler msg = new StringBundler(6);
10652    
10653                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10654    
10655                    msg.append("groupId=");
10656                    msg.append(groupId);
10657    
10658                    msg.append(", urlTitle=");
10659                    msg.append(urlTitle);
10660    
10661                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10662    
10663                    throw new NoSuchArticleException(msg.toString());
10664            }
10665    
10666            /**
10667             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
10668             *
10669             * @param groupId the group ID
10670             * @param urlTitle the url title
10671             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10672             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
10673             * @throws SystemException if a system exception occurred
10674             */
10675            @Override
10676            public JournalArticle fetchByG_UT_First(long groupId, String urlTitle,
10677                    OrderByComparator orderByComparator) throws SystemException {
10678                    List<JournalArticle> list = findByG_UT(groupId, urlTitle, 0, 1,
10679                                    orderByComparator);
10680    
10681                    if (!list.isEmpty()) {
10682                            return list.get(0);
10683                    }
10684    
10685                    return null;
10686            }
10687    
10688            /**
10689             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
10690             *
10691             * @param groupId the group ID
10692             * @param urlTitle the url title
10693             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10694             * @return the last matching journal article
10695             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10696             * @throws SystemException if a system exception occurred
10697             */
10698            @Override
10699            public JournalArticle findByG_UT_Last(long groupId, String urlTitle,
10700                    OrderByComparator orderByComparator)
10701                    throws NoSuchArticleException, SystemException {
10702                    JournalArticle journalArticle = fetchByG_UT_Last(groupId, urlTitle,
10703                                    orderByComparator);
10704    
10705                    if (journalArticle != null) {
10706                            return journalArticle;
10707                    }
10708    
10709                    StringBundler msg = new StringBundler(6);
10710    
10711                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10712    
10713                    msg.append("groupId=");
10714                    msg.append(groupId);
10715    
10716                    msg.append(", urlTitle=");
10717                    msg.append(urlTitle);
10718    
10719                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10720    
10721                    throw new NoSuchArticleException(msg.toString());
10722            }
10723    
10724            /**
10725             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
10726             *
10727             * @param groupId the group ID
10728             * @param urlTitle the url title
10729             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10730             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
10731             * @throws SystemException if a system exception occurred
10732             */
10733            @Override
10734            public JournalArticle fetchByG_UT_Last(long groupId, String urlTitle,
10735                    OrderByComparator orderByComparator) throws SystemException {
10736                    int count = countByG_UT(groupId, urlTitle);
10737    
10738                    if (count == 0) {
10739                            return null;
10740                    }
10741    
10742                    List<JournalArticle> list = findByG_UT(groupId, urlTitle, count - 1,
10743                                    count, orderByComparator);
10744    
10745                    if (!list.isEmpty()) {
10746                            return list.get(0);
10747                    }
10748    
10749                    return null;
10750            }
10751    
10752            /**
10753             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
10754             *
10755             * @param id the primary key of the current journal article
10756             * @param groupId the group ID
10757             * @param urlTitle the url title
10758             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10759             * @return the previous, current, and next journal article
10760             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
10761             * @throws SystemException if a system exception occurred
10762             */
10763            @Override
10764            public JournalArticle[] findByG_UT_PrevAndNext(long id, long groupId,
10765                    String urlTitle, OrderByComparator orderByComparator)
10766                    throws NoSuchArticleException, SystemException {
10767                    JournalArticle journalArticle = findByPrimaryKey(id);
10768    
10769                    Session session = null;
10770    
10771                    try {
10772                            session = openSession();
10773    
10774                            JournalArticle[] array = new JournalArticleImpl[3];
10775    
10776                            array[0] = getByG_UT_PrevAndNext(session, journalArticle, groupId,
10777                                            urlTitle, orderByComparator, true);
10778    
10779                            array[1] = journalArticle;
10780    
10781                            array[2] = getByG_UT_PrevAndNext(session, journalArticle, groupId,
10782                                            urlTitle, orderByComparator, false);
10783    
10784                            return array;
10785                    }
10786                    catch (Exception e) {
10787                            throw processException(e);
10788                    }
10789                    finally {
10790                            closeSession(session);
10791                    }
10792            }
10793    
10794            protected JournalArticle getByG_UT_PrevAndNext(Session session,
10795                    JournalArticle journalArticle, long groupId, String urlTitle,
10796                    OrderByComparator orderByComparator, boolean previous) {
10797                    StringBundler query = null;
10798    
10799                    if (orderByComparator != null) {
10800                            query = new StringBundler(6 +
10801                                            (orderByComparator.getOrderByFields().length * 6));
10802                    }
10803                    else {
10804                            query = new StringBundler(3);
10805                    }
10806    
10807                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10808    
10809                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
10810    
10811                    boolean bindUrlTitle = false;
10812    
10813                    if (urlTitle == null) {
10814                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
10815                    }
10816                    else if (urlTitle.equals(StringPool.BLANK)) {
10817                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
10818                    }
10819                    else {
10820                            bindUrlTitle = true;
10821    
10822                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
10823                    }
10824    
10825                    if (orderByComparator != null) {
10826                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10827    
10828                            if (orderByConditionFields.length > 0) {
10829                                    query.append(WHERE_AND);
10830                            }
10831    
10832                            for (int i = 0; i < orderByConditionFields.length; i++) {
10833                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10834                                    query.append(orderByConditionFields[i]);
10835    
10836                                    if ((i + 1) < orderByConditionFields.length) {
10837                                            if (orderByComparator.isAscending() ^ previous) {
10838                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10839                                            }
10840                                            else {
10841                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10842                                            }
10843                                    }
10844                                    else {
10845                                            if (orderByComparator.isAscending() ^ previous) {
10846                                                    query.append(WHERE_GREATER_THAN);
10847                                            }
10848                                            else {
10849                                                    query.append(WHERE_LESSER_THAN);
10850                                            }
10851                                    }
10852                            }
10853    
10854                            query.append(ORDER_BY_CLAUSE);
10855    
10856                            String[] orderByFields = orderByComparator.getOrderByFields();
10857    
10858                            for (int i = 0; i < orderByFields.length; i++) {
10859                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10860                                    query.append(orderByFields[i]);
10861    
10862                                    if ((i + 1) < orderByFields.length) {
10863                                            if (orderByComparator.isAscending() ^ previous) {
10864                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10865                                            }
10866                                            else {
10867                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10868                                            }
10869                                    }
10870                                    else {
10871                                            if (orderByComparator.isAscending() ^ previous) {
10872                                                    query.append(ORDER_BY_ASC);
10873                                            }
10874                                            else {
10875                                                    query.append(ORDER_BY_DESC);
10876                                            }
10877                                    }
10878                            }
10879                    }
10880                    else {
10881                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10882                    }
10883    
10884                    String sql = query.toString();
10885    
10886                    Query q = session.createQuery(sql);
10887    
10888                    q.setFirstResult(0);
10889                    q.setMaxResults(2);
10890    
10891                    QueryPos qPos = QueryPos.getInstance(q);
10892    
10893                    qPos.add(groupId);
10894    
10895                    if (bindUrlTitle) {
10896                            qPos.add(urlTitle);
10897                    }
10898    
10899                    if (orderByComparator != null) {
10900                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
10901    
10902                            for (Object value : values) {
10903                                    qPos.add(value);
10904                            }
10905                    }
10906    
10907                    List<JournalArticle> list = q.list();
10908    
10909                    if (list.size() == 2) {
10910                            return list.get(1);
10911                    }
10912                    else {
10913                            return null;
10914                    }
10915            }
10916    
10917            /**
10918             * Returns all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
10919             *
10920             * @param groupId the group ID
10921             * @param urlTitle the url title
10922             * @return the matching journal articles that the user has permission to view
10923             * @throws SystemException if a system exception occurred
10924             */
10925            @Override
10926            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle)
10927                    throws SystemException {
10928                    return filterFindByG_UT(groupId, urlTitle, QueryUtil.ALL_POS,
10929                            QueryUtil.ALL_POS, null);
10930            }
10931    
10932            /**
10933             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
10934             *
10935             * <p>
10936             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10937             * </p>
10938             *
10939             * @param groupId the group ID
10940             * @param urlTitle the url title
10941             * @param start the lower bound of the range of journal articles
10942             * @param end the upper bound of the range of journal articles (not inclusive)
10943             * @return the range of matching journal articles that the user has permission to view
10944             * @throws SystemException if a system exception occurred
10945             */
10946            @Override
10947            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle,
10948                    int start, int end) throws SystemException {
10949                    return filterFindByG_UT(groupId, urlTitle, start, end, null);
10950            }
10951    
10952            /**
10953             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and urlTitle = &#63;.
10954             *
10955             * <p>
10956             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10957             * </p>
10958             *
10959             * @param groupId the group ID
10960             * @param urlTitle the url title
10961             * @param start the lower bound of the range of journal articles
10962             * @param end the upper bound of the range of journal articles (not inclusive)
10963             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10964             * @return the ordered range of matching journal articles that the user has permission to view
10965             * @throws SystemException if a system exception occurred
10966             */
10967            @Override
10968            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle,
10969                    int start, int end, OrderByComparator orderByComparator)
10970                    throws SystemException {
10971                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10972                            return findByG_UT(groupId, urlTitle, start, end, orderByComparator);
10973                    }
10974    
10975                    StringBundler query = null;
10976    
10977                    if (orderByComparator != null) {
10978                            query = new StringBundler(4 +
10979                                            (orderByComparator.getOrderByFields().length * 3));
10980                    }
10981                    else {
10982                            query = new StringBundler(4);
10983                    }
10984    
10985                    if (getDB().isSupportsInlineDistinct()) {
10986                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
10987                    }
10988                    else {
10989                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
10990                    }
10991    
10992                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
10993    
10994                    boolean bindUrlTitle = false;
10995    
10996                    if (urlTitle == null) {
10997                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
10998                    }
10999                    else if (urlTitle.equals(StringPool.BLANK)) {
11000                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
11001                    }
11002                    else {
11003                            bindUrlTitle = true;
11004    
11005                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
11006                    }
11007    
11008                    if (!getDB().isSupportsInlineDistinct()) {
11009                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
11010                    }
11011    
11012                    if (orderByComparator != null) {
11013                            if (getDB().isSupportsInlineDistinct()) {
11014                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11015                                            orderByComparator, true);
11016                            }
11017                            else {
11018                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11019                                            orderByComparator, true);
11020                            }
11021                    }
11022                    else {
11023                            if (getDB().isSupportsInlineDistinct()) {
11024                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11025                            }
11026                            else {
11027                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
11028                            }
11029                    }
11030    
11031                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11032                                    JournalArticle.class.getName(),
11033                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11034    
11035                    Session session = null;
11036    
11037                    try {
11038                            session = openSession();
11039    
11040                            SQLQuery q = session.createSQLQuery(sql);
11041    
11042                            if (getDB().isSupportsInlineDistinct()) {
11043                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
11044                            }
11045                            else {
11046                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
11047                            }
11048    
11049                            QueryPos qPos = QueryPos.getInstance(q);
11050    
11051                            qPos.add(groupId);
11052    
11053                            if (bindUrlTitle) {
11054                                    qPos.add(urlTitle);
11055                            }
11056    
11057                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
11058                                    end);
11059                    }
11060                    catch (Exception e) {
11061                            throw processException(e);
11062                    }
11063                    finally {
11064                            closeSession(session);
11065                    }
11066            }
11067    
11068            /**
11069             * 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;.
11070             *
11071             * @param id the primary key of the current journal article
11072             * @param groupId the group ID
11073             * @param urlTitle the url title
11074             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11075             * @return the previous, current, and next journal article
11076             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
11077             * @throws SystemException if a system exception occurred
11078             */
11079            @Override
11080            public JournalArticle[] filterFindByG_UT_PrevAndNext(long id, long groupId,
11081                    String urlTitle, OrderByComparator orderByComparator)
11082                    throws NoSuchArticleException, SystemException {
11083                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11084                            return findByG_UT_PrevAndNext(id, groupId, urlTitle,
11085                                    orderByComparator);
11086                    }
11087    
11088                    JournalArticle journalArticle = findByPrimaryKey(id);
11089    
11090                    Session session = null;
11091    
11092                    try {
11093                            session = openSession();
11094    
11095                            JournalArticle[] array = new JournalArticleImpl[3];
11096    
11097                            array[0] = filterGetByG_UT_PrevAndNext(session, journalArticle,
11098                                            groupId, urlTitle, orderByComparator, true);
11099    
11100                            array[1] = journalArticle;
11101    
11102                            array[2] = filterGetByG_UT_PrevAndNext(session, journalArticle,
11103                                            groupId, urlTitle, orderByComparator, false);
11104    
11105                            return array;
11106                    }
11107                    catch (Exception e) {
11108                            throw processException(e);
11109                    }
11110                    finally {
11111                            closeSession(session);
11112                    }
11113            }
11114    
11115            protected JournalArticle filterGetByG_UT_PrevAndNext(Session session,
11116                    JournalArticle journalArticle, long groupId, String urlTitle,
11117                    OrderByComparator orderByComparator, boolean previous) {
11118                    StringBundler query = null;
11119    
11120                    if (orderByComparator != null) {
11121                            query = new StringBundler(6 +
11122                                            (orderByComparator.getOrderByFields().length * 6));
11123                    }
11124                    else {
11125                            query = new StringBundler(3);
11126                    }
11127    
11128                    if (getDB().isSupportsInlineDistinct()) {
11129                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
11130                    }
11131                    else {
11132                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
11133                    }
11134    
11135                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
11136    
11137                    boolean bindUrlTitle = false;
11138    
11139                    if (urlTitle == null) {
11140                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
11141                    }
11142                    else if (urlTitle.equals(StringPool.BLANK)) {
11143                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
11144                    }
11145                    else {
11146                            bindUrlTitle = true;
11147    
11148                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
11149                    }
11150    
11151                    if (!getDB().isSupportsInlineDistinct()) {
11152                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
11153                    }
11154    
11155                    if (orderByComparator != null) {
11156                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11157    
11158                            if (orderByConditionFields.length > 0) {
11159                                    query.append(WHERE_AND);
11160                            }
11161    
11162                            for (int i = 0; i < orderByConditionFields.length; i++) {
11163                                    if (getDB().isSupportsInlineDistinct()) {
11164                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11165                                    }
11166                                    else {
11167                                            query.append(_ORDER_BY_ENTITY_TABLE);
11168                                    }
11169    
11170                                    query.append(orderByConditionFields[i]);
11171    
11172                                    if ((i + 1) < orderByConditionFields.length) {
11173                                            if (orderByComparator.isAscending() ^ previous) {
11174                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11175                                            }
11176                                            else {
11177                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11178                                            }
11179                                    }
11180                                    else {
11181                                            if (orderByComparator.isAscending() ^ previous) {
11182                                                    query.append(WHERE_GREATER_THAN);
11183                                            }
11184                                            else {
11185                                                    query.append(WHERE_LESSER_THAN);
11186                                            }
11187                                    }
11188                            }
11189    
11190                            query.append(ORDER_BY_CLAUSE);
11191    
11192                            String[] orderByFields = orderByComparator.getOrderByFields();
11193    
11194                            for (int i = 0; i < orderByFields.length; i++) {
11195                                    if (getDB().isSupportsInlineDistinct()) {
11196                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11197                                    }
11198                                    else {
11199                                            query.append(_ORDER_BY_ENTITY_TABLE);
11200                                    }
11201    
11202                                    query.append(orderByFields[i]);
11203    
11204                                    if ((i + 1) < orderByFields.length) {
11205                                            if (orderByComparator.isAscending() ^ previous) {
11206                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11207                                            }
11208                                            else {
11209                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11210                                            }
11211                                    }
11212                                    else {
11213                                            if (orderByComparator.isAscending() ^ previous) {
11214                                                    query.append(ORDER_BY_ASC);
11215                                            }
11216                                            else {
11217                                                    query.append(ORDER_BY_DESC);
11218                                            }
11219                                    }
11220                            }
11221                    }
11222                    else {
11223                            if (getDB().isSupportsInlineDistinct()) {
11224                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11225                            }
11226                            else {
11227                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
11228                            }
11229                    }
11230    
11231                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11232                                    JournalArticle.class.getName(),
11233                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11234    
11235                    SQLQuery q = session.createSQLQuery(sql);
11236    
11237                    q.setFirstResult(0);
11238                    q.setMaxResults(2);
11239    
11240                    if (getDB().isSupportsInlineDistinct()) {
11241                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
11242                    }
11243                    else {
11244                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
11245                    }
11246    
11247                    QueryPos qPos = QueryPos.getInstance(q);
11248    
11249                    qPos.add(groupId);
11250    
11251                    if (bindUrlTitle) {
11252                            qPos.add(urlTitle);
11253                    }
11254    
11255                    if (orderByComparator != null) {
11256                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
11257    
11258                            for (Object value : values) {
11259                                    qPos.add(value);
11260                            }
11261                    }
11262    
11263                    List<JournalArticle> list = q.list();
11264    
11265                    if (list.size() == 2) {
11266                            return list.get(1);
11267                    }
11268                    else {
11269                            return null;
11270                    }
11271            }
11272    
11273            /**
11274             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; from the database.
11275             *
11276             * @param groupId the group ID
11277             * @param urlTitle the url title
11278             * @throws SystemException if a system exception occurred
11279             */
11280            @Override
11281            public void removeByG_UT(long groupId, String urlTitle)
11282                    throws SystemException {
11283                    for (JournalArticle journalArticle : findByG_UT(groupId, urlTitle,
11284                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
11285                            remove(journalArticle);
11286                    }
11287            }
11288    
11289            /**
11290             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63;.
11291             *
11292             * @param groupId the group ID
11293             * @param urlTitle the url title
11294             * @return the number of matching journal articles
11295             * @throws SystemException if a system exception occurred
11296             */
11297            @Override
11298            public int countByG_UT(long groupId, String urlTitle)
11299                    throws SystemException {
11300                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_UT;
11301    
11302                    Object[] finderArgs = new Object[] { groupId, urlTitle };
11303    
11304                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
11305                                    this);
11306    
11307                    if (count == null) {
11308                            StringBundler query = new StringBundler(3);
11309    
11310                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
11311    
11312                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
11313    
11314                            boolean bindUrlTitle = false;
11315    
11316                            if (urlTitle == null) {
11317                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
11318                            }
11319                            else if (urlTitle.equals(StringPool.BLANK)) {
11320                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
11321                            }
11322                            else {
11323                                    bindUrlTitle = true;
11324    
11325                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
11326                            }
11327    
11328                            String sql = query.toString();
11329    
11330                            Session session = null;
11331    
11332                            try {
11333                                    session = openSession();
11334    
11335                                    Query q = session.createQuery(sql);
11336    
11337                                    QueryPos qPos = QueryPos.getInstance(q);
11338    
11339                                    qPos.add(groupId);
11340    
11341                                    if (bindUrlTitle) {
11342                                            qPos.add(urlTitle);
11343                                    }
11344    
11345                                    count = (Long)q.uniqueResult();
11346    
11347                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
11348                            }
11349                            catch (Exception e) {
11350                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11351    
11352                                    throw processException(e);
11353                            }
11354                            finally {
11355                                    closeSession(session);
11356                            }
11357                    }
11358    
11359                    return count.intValue();
11360            }
11361    
11362            /**
11363             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
11364             *
11365             * @param groupId the group ID
11366             * @param urlTitle the url title
11367             * @return the number of matching journal articles that the user has permission to view
11368             * @throws SystemException if a system exception occurred
11369             */
11370            @Override
11371            public int filterCountByG_UT(long groupId, String urlTitle)
11372                    throws SystemException {
11373                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11374                            return countByG_UT(groupId, urlTitle);
11375                    }
11376    
11377                    StringBundler query = new StringBundler(3);
11378    
11379                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
11380    
11381                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
11382    
11383                    boolean bindUrlTitle = false;
11384    
11385                    if (urlTitle == null) {
11386                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
11387                    }
11388                    else if (urlTitle.equals(StringPool.BLANK)) {
11389                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
11390                    }
11391                    else {
11392                            bindUrlTitle = true;
11393    
11394                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
11395                    }
11396    
11397                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11398                                    JournalArticle.class.getName(),
11399                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11400    
11401                    Session session = null;
11402    
11403                    try {
11404                            session = openSession();
11405    
11406                            SQLQuery q = session.createSQLQuery(sql);
11407    
11408                            q.addScalar(COUNT_COLUMN_NAME,
11409                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11410    
11411                            QueryPos qPos = QueryPos.getInstance(q);
11412    
11413                            qPos.add(groupId);
11414    
11415                            if (bindUrlTitle) {
11416                                    qPos.add(urlTitle);
11417                            }
11418    
11419                            Long count = (Long)q.uniqueResult();
11420    
11421                            return count.intValue();
11422                    }
11423                    catch (Exception e) {
11424                            throw processException(e);
11425                    }
11426                    finally {
11427                            closeSession(session);
11428                    }
11429            }
11430    
11431            private static final String _FINDER_COLUMN_G_UT_GROUPID_2 = "journalArticle.groupId = ? AND ";
11432            private static final String _FINDER_COLUMN_G_UT_URLTITLE_1 = "journalArticle.urlTitle IS NULL";
11433            private static final String _FINDER_COLUMN_G_UT_URLTITLE_2 = "journalArticle.urlTitle = ?";
11434            private static final String _FINDER_COLUMN_G_UT_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = '')";
11435            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
11436                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
11437                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
11438                            "findByG_S",
11439                            new String[] {
11440                                    Long.class.getName(), String.class.getName(),
11441                                    
11442                            Integer.class.getName(), Integer.class.getName(),
11443                                    OrderByComparator.class.getName()
11444                            });
11445            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
11446                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
11447                            JournalArticleImpl.class,
11448                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
11449                            new String[] { Long.class.getName(), String.class.getName() },
11450                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
11451                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK |
11452                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
11453                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
11454            public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
11455                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
11456                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
11457                            new String[] { Long.class.getName(), String.class.getName() });
11458    
11459            /**
11460             * Returns all the journal articles where groupId = &#63; and structureId = &#63;.
11461             *
11462             * @param groupId the group ID
11463             * @param structureId the structure ID
11464             * @return the matching journal articles
11465             * @throws SystemException if a system exception occurred
11466             */
11467            @Override
11468            public List<JournalArticle> findByG_S(long groupId, String structureId)
11469                    throws SystemException {
11470                    return findByG_S(groupId, structureId, QueryUtil.ALL_POS,
11471                            QueryUtil.ALL_POS, null);
11472            }
11473    
11474            /**
11475             * Returns a range of all the journal articles where groupId = &#63; and structureId = &#63;.
11476             *
11477             * <p>
11478             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11479             * </p>
11480             *
11481             * @param groupId the group ID
11482             * @param structureId the structure ID
11483             * @param start the lower bound of the range of journal articles
11484             * @param end the upper bound of the range of journal articles (not inclusive)
11485             * @return the range of matching journal articles
11486             * @throws SystemException if a system exception occurred
11487             */
11488            @Override
11489            public List<JournalArticle> findByG_S(long groupId, String structureId,
11490                    int start, int end) throws SystemException {
11491                    return findByG_S(groupId, structureId, start, end, null);
11492            }
11493    
11494            /**
11495             * Returns an ordered range of all the journal articles where groupId = &#63; and structureId = &#63;.
11496             *
11497             * <p>
11498             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11499             * </p>
11500             *
11501             * @param groupId the group ID
11502             * @param structureId the structure ID
11503             * @param start the lower bound of the range of journal articles
11504             * @param end the upper bound of the range of journal articles (not inclusive)
11505             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11506             * @return the ordered range of matching journal articles
11507             * @throws SystemException if a system exception occurred
11508             */
11509            @Override
11510            public List<JournalArticle> findByG_S(long groupId, String structureId,
11511                    int start, int end, OrderByComparator orderByComparator)
11512                    throws SystemException {
11513                    boolean pagination = true;
11514                    FinderPath finderPath = null;
11515                    Object[] finderArgs = null;
11516    
11517                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11518                                    (orderByComparator == null)) {
11519                            pagination = false;
11520                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
11521                            finderArgs = new Object[] { groupId, structureId };
11522                    }
11523                    else {
11524                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
11525                            finderArgs = new Object[] {
11526                                            groupId, structureId,
11527                                            
11528                                            start, end, orderByComparator
11529                                    };
11530                    }
11531    
11532                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
11533                                    finderArgs, this);
11534    
11535                    if ((list != null) && !list.isEmpty()) {
11536                            for (JournalArticle journalArticle : list) {
11537                                    if ((groupId != journalArticle.getGroupId()) ||
11538                                                    !Validator.equals(structureId,
11539                                                            journalArticle.getStructureId())) {
11540                                            list = null;
11541    
11542                                            break;
11543                                    }
11544                            }
11545                    }
11546    
11547                    if (list == null) {
11548                            StringBundler query = null;
11549    
11550                            if (orderByComparator != null) {
11551                                    query = new StringBundler(4 +
11552                                                    (orderByComparator.getOrderByFields().length * 3));
11553                            }
11554                            else {
11555                                    query = new StringBundler(4);
11556                            }
11557    
11558                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11559    
11560                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
11561    
11562                            boolean bindStructureId = false;
11563    
11564                            if (structureId == null) {
11565                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
11566                            }
11567                            else if (structureId.equals(StringPool.BLANK)) {
11568                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
11569                            }
11570                            else {
11571                                    bindStructureId = true;
11572    
11573                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
11574                            }
11575    
11576                            if (orderByComparator != null) {
11577                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11578                                            orderByComparator);
11579                            }
11580                            else
11581                             if (pagination) {
11582                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11583                            }
11584    
11585                            String sql = query.toString();
11586    
11587                            Session session = null;
11588    
11589                            try {
11590                                    session = openSession();
11591    
11592                                    Query q = session.createQuery(sql);
11593    
11594                                    QueryPos qPos = QueryPos.getInstance(q);
11595    
11596                                    qPos.add(groupId);
11597    
11598                                    if (bindStructureId) {
11599                                            qPos.add(structureId);
11600                                    }
11601    
11602                                    if (!pagination) {
11603                                            list = (List<JournalArticle>)QueryUtil.list(q,
11604                                                            getDialect(), start, end, false);
11605    
11606                                            Collections.sort(list);
11607    
11608                                            list = new UnmodifiableList<JournalArticle>(list);
11609                                    }
11610                                    else {
11611                                            list = (List<JournalArticle>)QueryUtil.list(q,
11612                                                            getDialect(), start, end);
11613                                    }
11614    
11615                                    cacheResult(list);
11616    
11617                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
11618                            }
11619                            catch (Exception e) {
11620                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11621    
11622                                    throw processException(e);
11623                            }
11624                            finally {
11625                                    closeSession(session);
11626                            }
11627                    }
11628    
11629                    return list;
11630            }
11631    
11632            /**
11633             * Returns the first journal article in the ordered set where groupId = &#63; and structureId = &#63;.
11634             *
11635             * @param groupId the group ID
11636             * @param structureId the structure ID
11637             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11638             * @return the first matching journal article
11639             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11640             * @throws SystemException if a system exception occurred
11641             */
11642            @Override
11643            public JournalArticle findByG_S_First(long groupId, String structureId,
11644                    OrderByComparator orderByComparator)
11645                    throws NoSuchArticleException, SystemException {
11646                    JournalArticle journalArticle = fetchByG_S_First(groupId, structureId,
11647                                    orderByComparator);
11648    
11649                    if (journalArticle != null) {
11650                            return journalArticle;
11651                    }
11652    
11653                    StringBundler msg = new StringBundler(6);
11654    
11655                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11656    
11657                    msg.append("groupId=");
11658                    msg.append(groupId);
11659    
11660                    msg.append(", structureId=");
11661                    msg.append(structureId);
11662    
11663                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11664    
11665                    throw new NoSuchArticleException(msg.toString());
11666            }
11667    
11668            /**
11669             * Returns the first journal article in the ordered set where groupId = &#63; and structureId = &#63;.
11670             *
11671             * @param groupId the group ID
11672             * @param structureId the structure ID
11673             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11674             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
11675             * @throws SystemException if a system exception occurred
11676             */
11677            @Override
11678            public JournalArticle fetchByG_S_First(long groupId, String structureId,
11679                    OrderByComparator orderByComparator) throws SystemException {
11680                    List<JournalArticle> list = findByG_S(groupId, structureId, 0, 1,
11681                                    orderByComparator);
11682    
11683                    if (!list.isEmpty()) {
11684                            return list.get(0);
11685                    }
11686    
11687                    return null;
11688            }
11689    
11690            /**
11691             * Returns the last journal article in the ordered set where groupId = &#63; and structureId = &#63;.
11692             *
11693             * @param groupId the group ID
11694             * @param structureId the structure ID
11695             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11696             * @return the last matching journal article
11697             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11698             * @throws SystemException if a system exception occurred
11699             */
11700            @Override
11701            public JournalArticle findByG_S_Last(long groupId, String structureId,
11702                    OrderByComparator orderByComparator)
11703                    throws NoSuchArticleException, SystemException {
11704                    JournalArticle journalArticle = fetchByG_S_Last(groupId, structureId,
11705                                    orderByComparator);
11706    
11707                    if (journalArticle != null) {
11708                            return journalArticle;
11709                    }
11710    
11711                    StringBundler msg = new StringBundler(6);
11712    
11713                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11714    
11715                    msg.append("groupId=");
11716                    msg.append(groupId);
11717    
11718                    msg.append(", structureId=");
11719                    msg.append(structureId);
11720    
11721                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11722    
11723                    throw new NoSuchArticleException(msg.toString());
11724            }
11725    
11726            /**
11727             * Returns the last journal article in the ordered set where groupId = &#63; and structureId = &#63;.
11728             *
11729             * @param groupId the group ID
11730             * @param structureId the structure ID
11731             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11732             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
11733             * @throws SystemException if a system exception occurred
11734             */
11735            @Override
11736            public JournalArticle fetchByG_S_Last(long groupId, String structureId,
11737                    OrderByComparator orderByComparator) throws SystemException {
11738                    int count = countByG_S(groupId, structureId);
11739    
11740                    if (count == 0) {
11741                            return null;
11742                    }
11743    
11744                    List<JournalArticle> list = findByG_S(groupId, structureId, count - 1,
11745                                    count, orderByComparator);
11746    
11747                    if (!list.isEmpty()) {
11748                            return list.get(0);
11749                    }
11750    
11751                    return null;
11752            }
11753    
11754            /**
11755             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and structureId = &#63;.
11756             *
11757             * @param id the primary key of the current journal article
11758             * @param groupId the group ID
11759             * @param structureId the structure ID
11760             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11761             * @return the previous, current, and next journal article
11762             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
11763             * @throws SystemException if a system exception occurred
11764             */
11765            @Override
11766            public JournalArticle[] findByG_S_PrevAndNext(long id, long groupId,
11767                    String structureId, OrderByComparator orderByComparator)
11768                    throws NoSuchArticleException, SystemException {
11769                    JournalArticle journalArticle = findByPrimaryKey(id);
11770    
11771                    Session session = null;
11772    
11773                    try {
11774                            session = openSession();
11775    
11776                            JournalArticle[] array = new JournalArticleImpl[3];
11777    
11778                            array[0] = getByG_S_PrevAndNext(session, journalArticle, groupId,
11779                                            structureId, orderByComparator, true);
11780    
11781                            array[1] = journalArticle;
11782    
11783                            array[2] = getByG_S_PrevAndNext(session, journalArticle, groupId,
11784                                            structureId, orderByComparator, false);
11785    
11786                            return array;
11787                    }
11788                    catch (Exception e) {
11789                            throw processException(e);
11790                    }
11791                    finally {
11792                            closeSession(session);
11793                    }
11794            }
11795    
11796            protected JournalArticle getByG_S_PrevAndNext(Session session,
11797                    JournalArticle journalArticle, long groupId, String structureId,
11798                    OrderByComparator orderByComparator, boolean previous) {
11799                    StringBundler query = null;
11800    
11801                    if (orderByComparator != null) {
11802                            query = new StringBundler(6 +
11803                                            (orderByComparator.getOrderByFields().length * 6));
11804                    }
11805                    else {
11806                            query = new StringBundler(3);
11807                    }
11808    
11809                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11810    
11811                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
11812    
11813                    boolean bindStructureId = false;
11814    
11815                    if (structureId == null) {
11816                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
11817                    }
11818                    else if (structureId.equals(StringPool.BLANK)) {
11819                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
11820                    }
11821                    else {
11822                            bindStructureId = true;
11823    
11824                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
11825                    }
11826    
11827                    if (orderByComparator != null) {
11828                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11829    
11830                            if (orderByConditionFields.length > 0) {
11831                                    query.append(WHERE_AND);
11832                            }
11833    
11834                            for (int i = 0; i < orderByConditionFields.length; i++) {
11835                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11836                                    query.append(orderByConditionFields[i]);
11837    
11838                                    if ((i + 1) < orderByConditionFields.length) {
11839                                            if (orderByComparator.isAscending() ^ previous) {
11840                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11841                                            }
11842                                            else {
11843                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11844                                            }
11845                                    }
11846                                    else {
11847                                            if (orderByComparator.isAscending() ^ previous) {
11848                                                    query.append(WHERE_GREATER_THAN);
11849                                            }
11850                                            else {
11851                                                    query.append(WHERE_LESSER_THAN);
11852                                            }
11853                                    }
11854                            }
11855    
11856                            query.append(ORDER_BY_CLAUSE);
11857    
11858                            String[] orderByFields = orderByComparator.getOrderByFields();
11859    
11860                            for (int i = 0; i < orderByFields.length; i++) {
11861                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11862                                    query.append(orderByFields[i]);
11863    
11864                                    if ((i + 1) < orderByFields.length) {
11865                                            if (orderByComparator.isAscending() ^ previous) {
11866                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11867                                            }
11868                                            else {
11869                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11870                                            }
11871                                    }
11872                                    else {
11873                                            if (orderByComparator.isAscending() ^ previous) {
11874                                                    query.append(ORDER_BY_ASC);
11875                                            }
11876                                            else {
11877                                                    query.append(ORDER_BY_DESC);
11878                                            }
11879                                    }
11880                            }
11881                    }
11882                    else {
11883                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11884                    }
11885    
11886                    String sql = query.toString();
11887    
11888                    Query q = session.createQuery(sql);
11889    
11890                    q.setFirstResult(0);
11891                    q.setMaxResults(2);
11892    
11893                    QueryPos qPos = QueryPos.getInstance(q);
11894    
11895                    qPos.add(groupId);
11896    
11897                    if (bindStructureId) {
11898                            qPos.add(structureId);
11899                    }
11900    
11901                    if (orderByComparator != null) {
11902                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
11903    
11904                            for (Object value : values) {
11905                                    qPos.add(value);
11906                            }
11907                    }
11908    
11909                    List<JournalArticle> list = q.list();
11910    
11911                    if (list.size() == 2) {
11912                            return list.get(1);
11913                    }
11914                    else {
11915                            return null;
11916                    }
11917            }
11918    
11919            /**
11920             * Returns all the journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
11921             *
11922             * @param groupId the group ID
11923             * @param structureId the structure ID
11924             * @return the matching journal articles that the user has permission to view
11925             * @throws SystemException if a system exception occurred
11926             */
11927            @Override
11928            public List<JournalArticle> filterFindByG_S(long groupId, String structureId)
11929                    throws SystemException {
11930                    return filterFindByG_S(groupId, structureId, QueryUtil.ALL_POS,
11931                            QueryUtil.ALL_POS, null);
11932            }
11933    
11934            /**
11935             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
11936             *
11937             * <p>
11938             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11939             * </p>
11940             *
11941             * @param groupId the group ID
11942             * @param structureId the structure ID
11943             * @param start the lower bound of the range of journal articles
11944             * @param end the upper bound of the range of journal articles (not inclusive)
11945             * @return the range of matching journal articles that the user has permission to view
11946             * @throws SystemException if a system exception occurred
11947             */
11948            @Override
11949            public List<JournalArticle> filterFindByG_S(long groupId,
11950                    String structureId, int start, int end) throws SystemException {
11951                    return filterFindByG_S(groupId, structureId, start, end, null);
11952            }
11953    
11954            /**
11955             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and structureId = &#63;.
11956             *
11957             * <p>
11958             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11959             * </p>
11960             *
11961             * @param groupId the group ID
11962             * @param structureId the structure ID
11963             * @param start the lower bound of the range of journal articles
11964             * @param end the upper bound of the range of journal articles (not inclusive)
11965             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11966             * @return the ordered range of matching journal articles that the user has permission to view
11967             * @throws SystemException if a system exception occurred
11968             */
11969            @Override
11970            public List<JournalArticle> filterFindByG_S(long groupId,
11971                    String structureId, int start, int end,
11972                    OrderByComparator orderByComparator) throws SystemException {
11973                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11974                            return findByG_S(groupId, structureId, start, end, orderByComparator);
11975                    }
11976    
11977                    StringBundler query = null;
11978    
11979                    if (orderByComparator != null) {
11980                            query = new StringBundler(4 +
11981                                            (orderByComparator.getOrderByFields().length * 3));
11982                    }
11983                    else {
11984                            query = new StringBundler(4);
11985                    }
11986    
11987                    if (getDB().isSupportsInlineDistinct()) {
11988                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
11989                    }
11990                    else {
11991                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
11992                    }
11993    
11994                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
11995    
11996                    boolean bindStructureId = false;
11997    
11998                    if (structureId == null) {
11999                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
12000                    }
12001                    else if (structureId.equals(StringPool.BLANK)) {
12002                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
12003                    }
12004                    else {
12005                            bindStructureId = true;
12006    
12007                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
12008                    }
12009    
12010                    if (!getDB().isSupportsInlineDistinct()) {
12011                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
12012                    }
12013    
12014                    if (orderByComparator != null) {
12015                            if (getDB().isSupportsInlineDistinct()) {
12016                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12017                                            orderByComparator, true);
12018                            }
12019                            else {
12020                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12021                                            orderByComparator, true);
12022                            }
12023                    }
12024                    else {
12025                            if (getDB().isSupportsInlineDistinct()) {
12026                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12027                            }
12028                            else {
12029                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12030                            }
12031                    }
12032    
12033                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12034                                    JournalArticle.class.getName(),
12035                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12036    
12037                    Session session = null;
12038    
12039                    try {
12040                            session = openSession();
12041    
12042                            SQLQuery q = session.createSQLQuery(sql);
12043    
12044                            if (getDB().isSupportsInlineDistinct()) {
12045                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12046                            }
12047                            else {
12048                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12049                            }
12050    
12051                            QueryPos qPos = QueryPos.getInstance(q);
12052    
12053                            qPos.add(groupId);
12054    
12055                            if (bindStructureId) {
12056                                    qPos.add(structureId);
12057                            }
12058    
12059                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
12060                                    end);
12061                    }
12062                    catch (Exception e) {
12063                            throw processException(e);
12064                    }
12065                    finally {
12066                            closeSession(session);
12067                    }
12068            }
12069    
12070            /**
12071             * 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;.
12072             *
12073             * @param id the primary key of the current journal article
12074             * @param groupId the group ID
12075             * @param structureId the structure ID
12076             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12077             * @return the previous, current, and next journal article
12078             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
12079             * @throws SystemException if a system exception occurred
12080             */
12081            @Override
12082            public JournalArticle[] filterFindByG_S_PrevAndNext(long id, long groupId,
12083                    String structureId, OrderByComparator orderByComparator)
12084                    throws NoSuchArticleException, SystemException {
12085                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12086                            return findByG_S_PrevAndNext(id, groupId, structureId,
12087                                    orderByComparator);
12088                    }
12089    
12090                    JournalArticle journalArticle = findByPrimaryKey(id);
12091    
12092                    Session session = null;
12093    
12094                    try {
12095                            session = openSession();
12096    
12097                            JournalArticle[] array = new JournalArticleImpl[3];
12098    
12099                            array[0] = filterGetByG_S_PrevAndNext(session, journalArticle,
12100                                            groupId, structureId, orderByComparator, true);
12101    
12102                            array[1] = journalArticle;
12103    
12104                            array[2] = filterGetByG_S_PrevAndNext(session, journalArticle,
12105                                            groupId, structureId, orderByComparator, false);
12106    
12107                            return array;
12108                    }
12109                    catch (Exception e) {
12110                            throw processException(e);
12111                    }
12112                    finally {
12113                            closeSession(session);
12114                    }
12115            }
12116    
12117            protected JournalArticle filterGetByG_S_PrevAndNext(Session session,
12118                    JournalArticle journalArticle, long groupId, String structureId,
12119                    OrderByComparator orderByComparator, boolean previous) {
12120                    StringBundler query = null;
12121    
12122                    if (orderByComparator != null) {
12123                            query = new StringBundler(6 +
12124                                            (orderByComparator.getOrderByFields().length * 6));
12125                    }
12126                    else {
12127                            query = new StringBundler(3);
12128                    }
12129    
12130                    if (getDB().isSupportsInlineDistinct()) {
12131                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
12132                    }
12133                    else {
12134                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
12135                    }
12136    
12137                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
12138    
12139                    boolean bindStructureId = false;
12140    
12141                    if (structureId == null) {
12142                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
12143                    }
12144                    else if (structureId.equals(StringPool.BLANK)) {
12145                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
12146                    }
12147                    else {
12148                            bindStructureId = true;
12149    
12150                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
12151                    }
12152    
12153                    if (!getDB().isSupportsInlineDistinct()) {
12154                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
12155                    }
12156    
12157                    if (orderByComparator != null) {
12158                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12159    
12160                            if (orderByConditionFields.length > 0) {
12161                                    query.append(WHERE_AND);
12162                            }
12163    
12164                            for (int i = 0; i < orderByConditionFields.length; i++) {
12165                                    if (getDB().isSupportsInlineDistinct()) {
12166                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12167                                    }
12168                                    else {
12169                                            query.append(_ORDER_BY_ENTITY_TABLE);
12170                                    }
12171    
12172                                    query.append(orderByConditionFields[i]);
12173    
12174                                    if ((i + 1) < orderByConditionFields.length) {
12175                                            if (orderByComparator.isAscending() ^ previous) {
12176                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12177                                            }
12178                                            else {
12179                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12180                                            }
12181                                    }
12182                                    else {
12183                                            if (orderByComparator.isAscending() ^ previous) {
12184                                                    query.append(WHERE_GREATER_THAN);
12185                                            }
12186                                            else {
12187                                                    query.append(WHERE_LESSER_THAN);
12188                                            }
12189                                    }
12190                            }
12191    
12192                            query.append(ORDER_BY_CLAUSE);
12193    
12194                            String[] orderByFields = orderByComparator.getOrderByFields();
12195    
12196                            for (int i = 0; i < orderByFields.length; i++) {
12197                                    if (getDB().isSupportsInlineDistinct()) {
12198                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12199                                    }
12200                                    else {
12201                                            query.append(_ORDER_BY_ENTITY_TABLE);
12202                                    }
12203    
12204                                    query.append(orderByFields[i]);
12205    
12206                                    if ((i + 1) < orderByFields.length) {
12207                                            if (orderByComparator.isAscending() ^ previous) {
12208                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12209                                            }
12210                                            else {
12211                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12212                                            }
12213                                    }
12214                                    else {
12215                                            if (orderByComparator.isAscending() ^ previous) {
12216                                                    query.append(ORDER_BY_ASC);
12217                                            }
12218                                            else {
12219                                                    query.append(ORDER_BY_DESC);
12220                                            }
12221                                    }
12222                            }
12223                    }
12224                    else {
12225                            if (getDB().isSupportsInlineDistinct()) {
12226                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12227                            }
12228                            else {
12229                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12230                            }
12231                    }
12232    
12233                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12234                                    JournalArticle.class.getName(),
12235                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12236    
12237                    SQLQuery q = session.createSQLQuery(sql);
12238    
12239                    q.setFirstResult(0);
12240                    q.setMaxResults(2);
12241    
12242                    if (getDB().isSupportsInlineDistinct()) {
12243                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12244                    }
12245                    else {
12246                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12247                    }
12248    
12249                    QueryPos qPos = QueryPos.getInstance(q);
12250    
12251                    qPos.add(groupId);
12252    
12253                    if (bindStructureId) {
12254                            qPos.add(structureId);
12255                    }
12256    
12257                    if (orderByComparator != null) {
12258                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12259    
12260                            for (Object value : values) {
12261                                    qPos.add(value);
12262                            }
12263                    }
12264    
12265                    List<JournalArticle> list = q.list();
12266    
12267                    if (list.size() == 2) {
12268                            return list.get(1);
12269                    }
12270                    else {
12271                            return null;
12272                    }
12273            }
12274    
12275            /**
12276             * Removes all the journal articles where groupId = &#63; and structureId = &#63; from the database.
12277             *
12278             * @param groupId the group ID
12279             * @param structureId the structure ID
12280             * @throws SystemException if a system exception occurred
12281             */
12282            @Override
12283            public void removeByG_S(long groupId, String structureId)
12284                    throws SystemException {
12285                    for (JournalArticle journalArticle : findByG_S(groupId, structureId,
12286                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
12287                            remove(journalArticle);
12288                    }
12289            }
12290    
12291            /**
12292             * Returns the number of journal articles where groupId = &#63; and structureId = &#63;.
12293             *
12294             * @param groupId the group ID
12295             * @param structureId the structure ID
12296             * @return the number of matching journal articles
12297             * @throws SystemException if a system exception occurred
12298             */
12299            @Override
12300            public int countByG_S(long groupId, String structureId)
12301                    throws SystemException {
12302                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_S;
12303    
12304                    Object[] finderArgs = new Object[] { groupId, structureId };
12305    
12306                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
12307                                    this);
12308    
12309                    if (count == null) {
12310                            StringBundler query = new StringBundler(3);
12311    
12312                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
12313    
12314                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
12315    
12316                            boolean bindStructureId = false;
12317    
12318                            if (structureId == null) {
12319                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
12320                            }
12321                            else if (structureId.equals(StringPool.BLANK)) {
12322                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
12323                            }
12324                            else {
12325                                    bindStructureId = true;
12326    
12327                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
12328                            }
12329    
12330                            String sql = query.toString();
12331    
12332                            Session session = null;
12333    
12334                            try {
12335                                    session = openSession();
12336    
12337                                    Query q = session.createQuery(sql);
12338    
12339                                    QueryPos qPos = QueryPos.getInstance(q);
12340    
12341                                    qPos.add(groupId);
12342    
12343                                    if (bindStructureId) {
12344                                            qPos.add(structureId);
12345                                    }
12346    
12347                                    count = (Long)q.uniqueResult();
12348    
12349                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
12350                            }
12351                            catch (Exception e) {
12352                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12353    
12354                                    throw processException(e);
12355                            }
12356                            finally {
12357                                    closeSession(session);
12358                            }
12359                    }
12360    
12361                    return count.intValue();
12362            }
12363    
12364            /**
12365             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
12366             *
12367             * @param groupId the group ID
12368             * @param structureId the structure ID
12369             * @return the number of matching journal articles that the user has permission to view
12370             * @throws SystemException if a system exception occurred
12371             */
12372            @Override
12373            public int filterCountByG_S(long groupId, String structureId)
12374                    throws SystemException {
12375                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12376                            return countByG_S(groupId, structureId);
12377                    }
12378    
12379                    StringBundler query = new StringBundler(3);
12380    
12381                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
12382    
12383                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
12384    
12385                    boolean bindStructureId = false;
12386    
12387                    if (structureId == null) {
12388                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
12389                    }
12390                    else if (structureId.equals(StringPool.BLANK)) {
12391                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
12392                    }
12393                    else {
12394                            bindStructureId = true;
12395    
12396                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
12397                    }
12398    
12399                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12400                                    JournalArticle.class.getName(),
12401                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12402    
12403                    Session session = null;
12404    
12405                    try {
12406                            session = openSession();
12407    
12408                            SQLQuery q = session.createSQLQuery(sql);
12409    
12410                            q.addScalar(COUNT_COLUMN_NAME,
12411                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
12412    
12413                            QueryPos qPos = QueryPos.getInstance(q);
12414    
12415                            qPos.add(groupId);
12416    
12417                            if (bindStructureId) {
12418                                    qPos.add(structureId);
12419                            }
12420    
12421                            Long count = (Long)q.uniqueResult();
12422    
12423                            return count.intValue();
12424                    }
12425                    catch (Exception e) {
12426                            throw processException(e);
12427                    }
12428                    finally {
12429                            closeSession(session);
12430                    }
12431            }
12432    
12433            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
12434            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
12435            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
12436            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = '')";
12437            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
12438                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
12439                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
12440                            "findByG_T",
12441                            new String[] {
12442                                    Long.class.getName(), String.class.getName(),
12443                                    
12444                            Integer.class.getName(), Integer.class.getName(),
12445                                    OrderByComparator.class.getName()
12446                            });
12447            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
12448                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
12449                            JournalArticleImpl.class,
12450                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_T",
12451                            new String[] { Long.class.getName(), String.class.getName() },
12452                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
12453                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK |
12454                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
12455                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
12456            public static final FinderPath FINDER_PATH_COUNT_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
12457                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
12458                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_T",
12459                            new String[] { Long.class.getName(), String.class.getName() });
12460    
12461            /**
12462             * Returns all the journal articles where groupId = &#63; and templateId = &#63;.
12463             *
12464             * @param groupId the group ID
12465             * @param templateId the template ID
12466             * @return the matching journal articles
12467             * @throws SystemException if a system exception occurred
12468             */
12469            @Override
12470            public List<JournalArticle> findByG_T(long groupId, String templateId)
12471                    throws SystemException {
12472                    return findByG_T(groupId, templateId, QueryUtil.ALL_POS,
12473                            QueryUtil.ALL_POS, null);
12474            }
12475    
12476            /**
12477             * Returns a range of all the journal articles where groupId = &#63; and templateId = &#63;.
12478             *
12479             * <p>
12480             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12481             * </p>
12482             *
12483             * @param groupId the group ID
12484             * @param templateId the template ID
12485             * @param start the lower bound of the range of journal articles
12486             * @param end the upper bound of the range of journal articles (not inclusive)
12487             * @return the range of matching journal articles
12488             * @throws SystemException if a system exception occurred
12489             */
12490            @Override
12491            public List<JournalArticle> findByG_T(long groupId, String templateId,
12492                    int start, int end) throws SystemException {
12493                    return findByG_T(groupId, templateId, start, end, null);
12494            }
12495    
12496            /**
12497             * Returns an ordered range of all the journal articles where groupId = &#63; and templateId = &#63;.
12498             *
12499             * <p>
12500             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12501             * </p>
12502             *
12503             * @param groupId the group ID
12504             * @param templateId the template ID
12505             * @param start the lower bound of the range of journal articles
12506             * @param end the upper bound of the range of journal articles (not inclusive)
12507             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12508             * @return the ordered range of matching journal articles
12509             * @throws SystemException if a system exception occurred
12510             */
12511            @Override
12512            public List<JournalArticle> findByG_T(long groupId, String templateId,
12513                    int start, int end, OrderByComparator orderByComparator)
12514                    throws SystemException {
12515                    boolean pagination = true;
12516                    FinderPath finderPath = null;
12517                    Object[] finderArgs = null;
12518    
12519                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12520                                    (orderByComparator == null)) {
12521                            pagination = false;
12522                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T;
12523                            finderArgs = new Object[] { groupId, templateId };
12524                    }
12525                    else {
12526                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_T;
12527                            finderArgs = new Object[] {
12528                                            groupId, templateId,
12529                                            
12530                                            start, end, orderByComparator
12531                                    };
12532                    }
12533    
12534                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
12535                                    finderArgs, this);
12536    
12537                    if ((list != null) && !list.isEmpty()) {
12538                            for (JournalArticle journalArticle : list) {
12539                                    if ((groupId != journalArticle.getGroupId()) ||
12540                                                    !Validator.equals(templateId,
12541                                                            journalArticle.getTemplateId())) {
12542                                            list = null;
12543    
12544                                            break;
12545                                    }
12546                            }
12547                    }
12548    
12549                    if (list == null) {
12550                            StringBundler query = null;
12551    
12552                            if (orderByComparator != null) {
12553                                    query = new StringBundler(4 +
12554                                                    (orderByComparator.getOrderByFields().length * 3));
12555                            }
12556                            else {
12557                                    query = new StringBundler(4);
12558                            }
12559    
12560                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12561    
12562                            query.append(_FINDER_COLUMN_G_T_GROUPID_2);
12563    
12564                            boolean bindTemplateId = false;
12565    
12566                            if (templateId == null) {
12567                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
12568                            }
12569                            else if (templateId.equals(StringPool.BLANK)) {
12570                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
12571                            }
12572                            else {
12573                                    bindTemplateId = true;
12574    
12575                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
12576                            }
12577    
12578                            if (orderByComparator != null) {
12579                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12580                                            orderByComparator);
12581                            }
12582                            else
12583                             if (pagination) {
12584                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12585                            }
12586    
12587                            String sql = query.toString();
12588    
12589                            Session session = null;
12590    
12591                            try {
12592                                    session = openSession();
12593    
12594                                    Query q = session.createQuery(sql);
12595    
12596                                    QueryPos qPos = QueryPos.getInstance(q);
12597    
12598                                    qPos.add(groupId);
12599    
12600                                    if (bindTemplateId) {
12601                                            qPos.add(templateId);
12602                                    }
12603    
12604                                    if (!pagination) {
12605                                            list = (List<JournalArticle>)QueryUtil.list(q,
12606                                                            getDialect(), start, end, false);
12607    
12608                                            Collections.sort(list);
12609    
12610                                            list = new UnmodifiableList<JournalArticle>(list);
12611                                    }
12612                                    else {
12613                                            list = (List<JournalArticle>)QueryUtil.list(q,
12614                                                            getDialect(), start, end);
12615                                    }
12616    
12617                                    cacheResult(list);
12618    
12619                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
12620                            }
12621                            catch (Exception e) {
12622                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12623    
12624                                    throw processException(e);
12625                            }
12626                            finally {
12627                                    closeSession(session);
12628                            }
12629                    }
12630    
12631                    return list;
12632            }
12633    
12634            /**
12635             * Returns the first journal article in the ordered set where groupId = &#63; and templateId = &#63;.
12636             *
12637             * @param groupId the group ID
12638             * @param templateId the template ID
12639             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12640             * @return the first matching journal article
12641             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12642             * @throws SystemException if a system exception occurred
12643             */
12644            @Override
12645            public JournalArticle findByG_T_First(long groupId, String templateId,
12646                    OrderByComparator orderByComparator)
12647                    throws NoSuchArticleException, SystemException {
12648                    JournalArticle journalArticle = fetchByG_T_First(groupId, templateId,
12649                                    orderByComparator);
12650    
12651                    if (journalArticle != null) {
12652                            return journalArticle;
12653                    }
12654    
12655                    StringBundler msg = new StringBundler(6);
12656    
12657                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12658    
12659                    msg.append("groupId=");
12660                    msg.append(groupId);
12661    
12662                    msg.append(", templateId=");
12663                    msg.append(templateId);
12664    
12665                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12666    
12667                    throw new NoSuchArticleException(msg.toString());
12668            }
12669    
12670            /**
12671             * Returns the first journal article in the ordered set where groupId = &#63; and templateId = &#63;.
12672             *
12673             * @param groupId the group ID
12674             * @param templateId the template ID
12675             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12676             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
12677             * @throws SystemException if a system exception occurred
12678             */
12679            @Override
12680            public JournalArticle fetchByG_T_First(long groupId, String templateId,
12681                    OrderByComparator orderByComparator) throws SystemException {
12682                    List<JournalArticle> list = findByG_T(groupId, templateId, 0, 1,
12683                                    orderByComparator);
12684    
12685                    if (!list.isEmpty()) {
12686                            return list.get(0);
12687                    }
12688    
12689                    return null;
12690            }
12691    
12692            /**
12693             * Returns the last journal article in the ordered set where groupId = &#63; and templateId = &#63;.
12694             *
12695             * @param groupId the group ID
12696             * @param templateId the template ID
12697             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12698             * @return the last matching journal article
12699             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12700             * @throws SystemException if a system exception occurred
12701             */
12702            @Override
12703            public JournalArticle findByG_T_Last(long groupId, String templateId,
12704                    OrderByComparator orderByComparator)
12705                    throws NoSuchArticleException, SystemException {
12706                    JournalArticle journalArticle = fetchByG_T_Last(groupId, templateId,
12707                                    orderByComparator);
12708    
12709                    if (journalArticle != null) {
12710                            return journalArticle;
12711                    }
12712    
12713                    StringBundler msg = new StringBundler(6);
12714    
12715                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12716    
12717                    msg.append("groupId=");
12718                    msg.append(groupId);
12719    
12720                    msg.append(", templateId=");
12721                    msg.append(templateId);
12722    
12723                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12724    
12725                    throw new NoSuchArticleException(msg.toString());
12726            }
12727    
12728            /**
12729             * Returns the last journal article in the ordered set where groupId = &#63; and templateId = &#63;.
12730             *
12731             * @param groupId the group ID
12732             * @param templateId the template ID
12733             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12734             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
12735             * @throws SystemException if a system exception occurred
12736             */
12737            @Override
12738            public JournalArticle fetchByG_T_Last(long groupId, String templateId,
12739                    OrderByComparator orderByComparator) throws SystemException {
12740                    int count = countByG_T(groupId, templateId);
12741    
12742                    if (count == 0) {
12743                            return null;
12744                    }
12745    
12746                    List<JournalArticle> list = findByG_T(groupId, templateId, count - 1,
12747                                    count, orderByComparator);
12748    
12749                    if (!list.isEmpty()) {
12750                            return list.get(0);
12751                    }
12752    
12753                    return null;
12754            }
12755    
12756            /**
12757             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and templateId = &#63;.
12758             *
12759             * @param id the primary key of the current journal article
12760             * @param groupId the group ID
12761             * @param templateId the template ID
12762             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12763             * @return the previous, current, and next journal article
12764             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
12765             * @throws SystemException if a system exception occurred
12766             */
12767            @Override
12768            public JournalArticle[] findByG_T_PrevAndNext(long id, long groupId,
12769                    String templateId, OrderByComparator orderByComparator)
12770                    throws NoSuchArticleException, SystemException {
12771                    JournalArticle journalArticle = findByPrimaryKey(id);
12772    
12773                    Session session = null;
12774    
12775                    try {
12776                            session = openSession();
12777    
12778                            JournalArticle[] array = new JournalArticleImpl[3];
12779    
12780                            array[0] = getByG_T_PrevAndNext(session, journalArticle, groupId,
12781                                            templateId, orderByComparator, true);
12782    
12783                            array[1] = journalArticle;
12784    
12785                            array[2] = getByG_T_PrevAndNext(session, journalArticle, groupId,
12786                                            templateId, orderByComparator, false);
12787    
12788                            return array;
12789                    }
12790                    catch (Exception e) {
12791                            throw processException(e);
12792                    }
12793                    finally {
12794                            closeSession(session);
12795                    }
12796            }
12797    
12798            protected JournalArticle getByG_T_PrevAndNext(Session session,
12799                    JournalArticle journalArticle, long groupId, String templateId,
12800                    OrderByComparator orderByComparator, boolean previous) {
12801                    StringBundler query = null;
12802    
12803                    if (orderByComparator != null) {
12804                            query = new StringBundler(6 +
12805                                            (orderByComparator.getOrderByFields().length * 6));
12806                    }
12807                    else {
12808                            query = new StringBundler(3);
12809                    }
12810    
12811                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12812    
12813                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
12814    
12815                    boolean bindTemplateId = false;
12816    
12817                    if (templateId == null) {
12818                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
12819                    }
12820                    else if (templateId.equals(StringPool.BLANK)) {
12821                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
12822                    }
12823                    else {
12824                            bindTemplateId = true;
12825    
12826                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
12827                    }
12828    
12829                    if (orderByComparator != null) {
12830                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12831    
12832                            if (orderByConditionFields.length > 0) {
12833                                    query.append(WHERE_AND);
12834                            }
12835    
12836                            for (int i = 0; i < orderByConditionFields.length; i++) {
12837                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12838                                    query.append(orderByConditionFields[i]);
12839    
12840                                    if ((i + 1) < orderByConditionFields.length) {
12841                                            if (orderByComparator.isAscending() ^ previous) {
12842                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12843                                            }
12844                                            else {
12845                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12846                                            }
12847                                    }
12848                                    else {
12849                                            if (orderByComparator.isAscending() ^ previous) {
12850                                                    query.append(WHERE_GREATER_THAN);
12851                                            }
12852                                            else {
12853                                                    query.append(WHERE_LESSER_THAN);
12854                                            }
12855                                    }
12856                            }
12857    
12858                            query.append(ORDER_BY_CLAUSE);
12859    
12860                            String[] orderByFields = orderByComparator.getOrderByFields();
12861    
12862                            for (int i = 0; i < orderByFields.length; i++) {
12863                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12864                                    query.append(orderByFields[i]);
12865    
12866                                    if ((i + 1) < orderByFields.length) {
12867                                            if (orderByComparator.isAscending() ^ previous) {
12868                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12869                                            }
12870                                            else {
12871                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12872                                            }
12873                                    }
12874                                    else {
12875                                            if (orderByComparator.isAscending() ^ previous) {
12876                                                    query.append(ORDER_BY_ASC);
12877                                            }
12878                                            else {
12879                                                    query.append(ORDER_BY_DESC);
12880                                            }
12881                                    }
12882                            }
12883                    }
12884                    else {
12885                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12886                    }
12887    
12888                    String sql = query.toString();
12889    
12890                    Query q = session.createQuery(sql);
12891    
12892                    q.setFirstResult(0);
12893                    q.setMaxResults(2);
12894    
12895                    QueryPos qPos = QueryPos.getInstance(q);
12896    
12897                    qPos.add(groupId);
12898    
12899                    if (bindTemplateId) {
12900                            qPos.add(templateId);
12901                    }
12902    
12903                    if (orderByComparator != null) {
12904                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12905    
12906                            for (Object value : values) {
12907                                    qPos.add(value);
12908                            }
12909                    }
12910    
12911                    List<JournalArticle> list = q.list();
12912    
12913                    if (list.size() == 2) {
12914                            return list.get(1);
12915                    }
12916                    else {
12917                            return null;
12918                    }
12919            }
12920    
12921            /**
12922             * Returns all the journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
12923             *
12924             * @param groupId the group ID
12925             * @param templateId the template ID
12926             * @return the matching journal articles that the user has permission to view
12927             * @throws SystemException if a system exception occurred
12928             */
12929            @Override
12930            public List<JournalArticle> filterFindByG_T(long groupId, String templateId)
12931                    throws SystemException {
12932                    return filterFindByG_T(groupId, templateId, QueryUtil.ALL_POS,
12933                            QueryUtil.ALL_POS, null);
12934            }
12935    
12936            /**
12937             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
12938             *
12939             * <p>
12940             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12941             * </p>
12942             *
12943             * @param groupId the group ID
12944             * @param templateId the template ID
12945             * @param start the lower bound of the range of journal articles
12946             * @param end the upper bound of the range of journal articles (not inclusive)
12947             * @return the range of matching journal articles that the user has permission to view
12948             * @throws SystemException if a system exception occurred
12949             */
12950            @Override
12951            public List<JournalArticle> filterFindByG_T(long groupId,
12952                    String templateId, int start, int end) throws SystemException {
12953                    return filterFindByG_T(groupId, templateId, start, end, null);
12954            }
12955    
12956            /**
12957             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and templateId = &#63;.
12958             *
12959             * <p>
12960             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12961             * </p>
12962             *
12963             * @param groupId the group ID
12964             * @param templateId the template ID
12965             * @param start the lower bound of the range of journal articles
12966             * @param end the upper bound of the range of journal articles (not inclusive)
12967             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12968             * @return the ordered range of matching journal articles that the user has permission to view
12969             * @throws SystemException if a system exception occurred
12970             */
12971            @Override
12972            public List<JournalArticle> filterFindByG_T(long groupId,
12973                    String templateId, int start, int end,
12974                    OrderByComparator orderByComparator) throws SystemException {
12975                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12976                            return findByG_T(groupId, templateId, start, end, orderByComparator);
12977                    }
12978    
12979                    StringBundler query = null;
12980    
12981                    if (orderByComparator != null) {
12982                            query = new StringBundler(4 +
12983                                            (orderByComparator.getOrderByFields().length * 3));
12984                    }
12985                    else {
12986                            query = new StringBundler(4);
12987                    }
12988    
12989                    if (getDB().isSupportsInlineDistinct()) {
12990                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
12991                    }
12992                    else {
12993                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
12994                    }
12995    
12996                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
12997    
12998                    boolean bindTemplateId = false;
12999    
13000                    if (templateId == null) {
13001                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
13002                    }
13003                    else if (templateId.equals(StringPool.BLANK)) {
13004                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
13005                    }
13006                    else {
13007                            bindTemplateId = true;
13008    
13009                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
13010                    }
13011    
13012                    if (!getDB().isSupportsInlineDistinct()) {
13013                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
13014                    }
13015    
13016                    if (orderByComparator != null) {
13017                            if (getDB().isSupportsInlineDistinct()) {
13018                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13019                                            orderByComparator, true);
13020                            }
13021                            else {
13022                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
13023                                            orderByComparator, true);
13024                            }
13025                    }
13026                    else {
13027                            if (getDB().isSupportsInlineDistinct()) {
13028                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13029                            }
13030                            else {
13031                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
13032                            }
13033                    }
13034    
13035                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13036                                    JournalArticle.class.getName(),
13037                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13038    
13039                    Session session = null;
13040    
13041                    try {
13042                            session = openSession();
13043    
13044                            SQLQuery q = session.createSQLQuery(sql);
13045    
13046                            if (getDB().isSupportsInlineDistinct()) {
13047                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
13048                            }
13049                            else {
13050                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
13051                            }
13052    
13053                            QueryPos qPos = QueryPos.getInstance(q);
13054    
13055                            qPos.add(groupId);
13056    
13057                            if (bindTemplateId) {
13058                                    qPos.add(templateId);
13059                            }
13060    
13061                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
13062                                    end);
13063                    }
13064                    catch (Exception e) {
13065                            throw processException(e);
13066                    }
13067                    finally {
13068                            closeSession(session);
13069                    }
13070            }
13071    
13072            /**
13073             * 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;.
13074             *
13075             * @param id the primary key of the current journal article
13076             * @param groupId the group ID
13077             * @param templateId the template ID
13078             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13079             * @return the previous, current, and next journal article
13080             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13081             * @throws SystemException if a system exception occurred
13082             */
13083            @Override
13084            public JournalArticle[] filterFindByG_T_PrevAndNext(long id, long groupId,
13085                    String templateId, OrderByComparator orderByComparator)
13086                    throws NoSuchArticleException, SystemException {
13087                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13088                            return findByG_T_PrevAndNext(id, groupId, templateId,
13089                                    orderByComparator);
13090                    }
13091    
13092                    JournalArticle journalArticle = findByPrimaryKey(id);
13093    
13094                    Session session = null;
13095    
13096                    try {
13097                            session = openSession();
13098    
13099                            JournalArticle[] array = new JournalArticleImpl[3];
13100    
13101                            array[0] = filterGetByG_T_PrevAndNext(session, journalArticle,
13102                                            groupId, templateId, orderByComparator, true);
13103    
13104                            array[1] = journalArticle;
13105    
13106                            array[2] = filterGetByG_T_PrevAndNext(session, journalArticle,
13107                                            groupId, templateId, orderByComparator, false);
13108    
13109                            return array;
13110                    }
13111                    catch (Exception e) {
13112                            throw processException(e);
13113                    }
13114                    finally {
13115                            closeSession(session);
13116                    }
13117            }
13118    
13119            protected JournalArticle filterGetByG_T_PrevAndNext(Session session,
13120                    JournalArticle journalArticle, long groupId, String templateId,
13121                    OrderByComparator orderByComparator, boolean previous) {
13122                    StringBundler query = null;
13123    
13124                    if (orderByComparator != null) {
13125                            query = new StringBundler(6 +
13126                                            (orderByComparator.getOrderByFields().length * 6));
13127                    }
13128                    else {
13129                            query = new StringBundler(3);
13130                    }
13131    
13132                    if (getDB().isSupportsInlineDistinct()) {
13133                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
13134                    }
13135                    else {
13136                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
13137                    }
13138    
13139                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
13140    
13141                    boolean bindTemplateId = false;
13142    
13143                    if (templateId == null) {
13144                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
13145                    }
13146                    else if (templateId.equals(StringPool.BLANK)) {
13147                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
13148                    }
13149                    else {
13150                            bindTemplateId = true;
13151    
13152                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
13153                    }
13154    
13155                    if (!getDB().isSupportsInlineDistinct()) {
13156                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
13157                    }
13158    
13159                    if (orderByComparator != null) {
13160                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13161    
13162                            if (orderByConditionFields.length > 0) {
13163                                    query.append(WHERE_AND);
13164                            }
13165    
13166                            for (int i = 0; i < orderByConditionFields.length; i++) {
13167                                    if (getDB().isSupportsInlineDistinct()) {
13168                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13169                                    }
13170                                    else {
13171                                            query.append(_ORDER_BY_ENTITY_TABLE);
13172                                    }
13173    
13174                                    query.append(orderByConditionFields[i]);
13175    
13176                                    if ((i + 1) < orderByConditionFields.length) {
13177                                            if (orderByComparator.isAscending() ^ previous) {
13178                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13179                                            }
13180                                            else {
13181                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13182                                            }
13183                                    }
13184                                    else {
13185                                            if (orderByComparator.isAscending() ^ previous) {
13186                                                    query.append(WHERE_GREATER_THAN);
13187                                            }
13188                                            else {
13189                                                    query.append(WHERE_LESSER_THAN);
13190                                            }
13191                                    }
13192                            }
13193    
13194                            query.append(ORDER_BY_CLAUSE);
13195    
13196                            String[] orderByFields = orderByComparator.getOrderByFields();
13197    
13198                            for (int i = 0; i < orderByFields.length; i++) {
13199                                    if (getDB().isSupportsInlineDistinct()) {
13200                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13201                                    }
13202                                    else {
13203                                            query.append(_ORDER_BY_ENTITY_TABLE);
13204                                    }
13205    
13206                                    query.append(orderByFields[i]);
13207    
13208                                    if ((i + 1) < orderByFields.length) {
13209                                            if (orderByComparator.isAscending() ^ previous) {
13210                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13211                                            }
13212                                            else {
13213                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13214                                            }
13215                                    }
13216                                    else {
13217                                            if (orderByComparator.isAscending() ^ previous) {
13218                                                    query.append(ORDER_BY_ASC);
13219                                            }
13220                                            else {
13221                                                    query.append(ORDER_BY_DESC);
13222                                            }
13223                                    }
13224                            }
13225                    }
13226                    else {
13227                            if (getDB().isSupportsInlineDistinct()) {
13228                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13229                            }
13230                            else {
13231                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
13232                            }
13233                    }
13234    
13235                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13236                                    JournalArticle.class.getName(),
13237                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13238    
13239                    SQLQuery q = session.createSQLQuery(sql);
13240    
13241                    q.setFirstResult(0);
13242                    q.setMaxResults(2);
13243    
13244                    if (getDB().isSupportsInlineDistinct()) {
13245                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
13246                    }
13247                    else {
13248                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
13249                    }
13250    
13251                    QueryPos qPos = QueryPos.getInstance(q);
13252    
13253                    qPos.add(groupId);
13254    
13255                    if (bindTemplateId) {
13256                            qPos.add(templateId);
13257                    }
13258    
13259                    if (orderByComparator != null) {
13260                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13261    
13262                            for (Object value : values) {
13263                                    qPos.add(value);
13264                            }
13265                    }
13266    
13267                    List<JournalArticle> list = q.list();
13268    
13269                    if (list.size() == 2) {
13270                            return list.get(1);
13271                    }
13272                    else {
13273                            return null;
13274                    }
13275            }
13276    
13277            /**
13278             * Removes all the journal articles where groupId = &#63; and templateId = &#63; from the database.
13279             *
13280             * @param groupId the group ID
13281             * @param templateId the template ID
13282             * @throws SystemException if a system exception occurred
13283             */
13284            @Override
13285            public void removeByG_T(long groupId, String templateId)
13286                    throws SystemException {
13287                    for (JournalArticle journalArticle : findByG_T(groupId, templateId,
13288                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
13289                            remove(journalArticle);
13290                    }
13291            }
13292    
13293            /**
13294             * Returns the number of journal articles where groupId = &#63; and templateId = &#63;.
13295             *
13296             * @param groupId the group ID
13297             * @param templateId the template ID
13298             * @return the number of matching journal articles
13299             * @throws SystemException if a system exception occurred
13300             */
13301            @Override
13302            public int countByG_T(long groupId, String templateId)
13303                    throws SystemException {
13304                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_T;
13305    
13306                    Object[] finderArgs = new Object[] { groupId, templateId };
13307    
13308                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
13309                                    this);
13310    
13311                    if (count == null) {
13312                            StringBundler query = new StringBundler(3);
13313    
13314                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
13315    
13316                            query.append(_FINDER_COLUMN_G_T_GROUPID_2);
13317    
13318                            boolean bindTemplateId = false;
13319    
13320                            if (templateId == null) {
13321                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
13322                            }
13323                            else if (templateId.equals(StringPool.BLANK)) {
13324                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
13325                            }
13326                            else {
13327                                    bindTemplateId = true;
13328    
13329                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
13330                            }
13331    
13332                            String sql = query.toString();
13333    
13334                            Session session = null;
13335    
13336                            try {
13337                                    session = openSession();
13338    
13339                                    Query q = session.createQuery(sql);
13340    
13341                                    QueryPos qPos = QueryPos.getInstance(q);
13342    
13343                                    qPos.add(groupId);
13344    
13345                                    if (bindTemplateId) {
13346                                            qPos.add(templateId);
13347                                    }
13348    
13349                                    count = (Long)q.uniqueResult();
13350    
13351                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
13352                            }
13353                            catch (Exception e) {
13354                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13355    
13356                                    throw processException(e);
13357                            }
13358                            finally {
13359                                    closeSession(session);
13360                            }
13361                    }
13362    
13363                    return count.intValue();
13364            }
13365    
13366            /**
13367             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
13368             *
13369             * @param groupId the group ID
13370             * @param templateId the template ID
13371             * @return the number of matching journal articles that the user has permission to view
13372             * @throws SystemException if a system exception occurred
13373             */
13374            @Override
13375            public int filterCountByG_T(long groupId, String templateId)
13376                    throws SystemException {
13377                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13378                            return countByG_T(groupId, templateId);
13379                    }
13380    
13381                    StringBundler query = new StringBundler(3);
13382    
13383                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
13384    
13385                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
13386    
13387                    boolean bindTemplateId = false;
13388    
13389                    if (templateId == null) {
13390                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
13391                    }
13392                    else if (templateId.equals(StringPool.BLANK)) {
13393                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
13394                    }
13395                    else {
13396                            bindTemplateId = true;
13397    
13398                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
13399                    }
13400    
13401                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13402                                    JournalArticle.class.getName(),
13403                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13404    
13405                    Session session = null;
13406    
13407                    try {
13408                            session = openSession();
13409    
13410                            SQLQuery q = session.createSQLQuery(sql);
13411    
13412                            q.addScalar(COUNT_COLUMN_NAME,
13413                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
13414    
13415                            QueryPos qPos = QueryPos.getInstance(q);
13416    
13417                            qPos.add(groupId);
13418    
13419                            if (bindTemplateId) {
13420                                    qPos.add(templateId);
13421                            }
13422    
13423                            Long count = (Long)q.uniqueResult();
13424    
13425                            return count.intValue();
13426                    }
13427                    catch (Exception e) {
13428                            throw processException(e);
13429                    }
13430                    finally {
13431                            closeSession(session);
13432                    }
13433            }
13434    
13435            private static final String _FINDER_COLUMN_G_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
13436            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
13437            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
13438            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = '')";
13439            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13440                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
13441                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
13442                            "findByG_L",
13443                            new String[] {
13444                                    Long.class.getName(), String.class.getName(),
13445                                    
13446                            Integer.class.getName(), Integer.class.getName(),
13447                                    OrderByComparator.class.getName()
13448                            });
13449            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13450                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
13451                            JournalArticleImpl.class,
13452                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_L",
13453                            new String[] { Long.class.getName(), String.class.getName() },
13454                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
13455                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK |
13456                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
13457                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
13458            public static final FinderPath FINDER_PATH_COUNT_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13459                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
13460                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_L",
13461                            new String[] { Long.class.getName(), String.class.getName() });
13462    
13463            /**
13464             * Returns all the journal articles where groupId = &#63; and layoutUuid = &#63;.
13465             *
13466             * @param groupId the group ID
13467             * @param layoutUuid the layout uuid
13468             * @return the matching journal articles
13469             * @throws SystemException if a system exception occurred
13470             */
13471            @Override
13472            public List<JournalArticle> findByG_L(long groupId, String layoutUuid)
13473                    throws SystemException {
13474                    return findByG_L(groupId, layoutUuid, QueryUtil.ALL_POS,
13475                            QueryUtil.ALL_POS, null);
13476            }
13477    
13478            /**
13479             * Returns a range of all the journal articles where groupId = &#63; and layoutUuid = &#63;.
13480             *
13481             * <p>
13482             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13483             * </p>
13484             *
13485             * @param groupId the group ID
13486             * @param layoutUuid the layout uuid
13487             * @param start the lower bound of the range of journal articles
13488             * @param end the upper bound of the range of journal articles (not inclusive)
13489             * @return the range of matching journal articles
13490             * @throws SystemException if a system exception occurred
13491             */
13492            @Override
13493            public List<JournalArticle> findByG_L(long groupId, String layoutUuid,
13494                    int start, int end) throws SystemException {
13495                    return findByG_L(groupId, layoutUuid, start, end, null);
13496            }
13497    
13498            /**
13499             * Returns an ordered range of all the journal articles where groupId = &#63; and layoutUuid = &#63;.
13500             *
13501             * <p>
13502             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13503             * </p>
13504             *
13505             * @param groupId the group ID
13506             * @param layoutUuid the layout uuid
13507             * @param start the lower bound of the range of journal articles
13508             * @param end the upper bound of the range of journal articles (not inclusive)
13509             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13510             * @return the ordered range of matching journal articles
13511             * @throws SystemException if a system exception occurred
13512             */
13513            @Override
13514            public List<JournalArticle> findByG_L(long groupId, String layoutUuid,
13515                    int start, int end, OrderByComparator orderByComparator)
13516                    throws SystemException {
13517                    boolean pagination = true;
13518                    FinderPath finderPath = null;
13519                    Object[] finderArgs = null;
13520    
13521                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13522                                    (orderByComparator == null)) {
13523                            pagination = false;
13524                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L;
13525                            finderArgs = new Object[] { groupId, layoutUuid };
13526                    }
13527                    else {
13528                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_L;
13529                            finderArgs = new Object[] {
13530                                            groupId, layoutUuid,
13531                                            
13532                                            start, end, orderByComparator
13533                                    };
13534                    }
13535    
13536                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
13537                                    finderArgs, this);
13538    
13539                    if ((list != null) && !list.isEmpty()) {
13540                            for (JournalArticle journalArticle : list) {
13541                                    if ((groupId != journalArticle.getGroupId()) ||
13542                                                    !Validator.equals(layoutUuid,
13543                                                            journalArticle.getLayoutUuid())) {
13544                                            list = null;
13545    
13546                                            break;
13547                                    }
13548                            }
13549                    }
13550    
13551                    if (list == null) {
13552                            StringBundler query = null;
13553    
13554                            if (orderByComparator != null) {
13555                                    query = new StringBundler(4 +
13556                                                    (orderByComparator.getOrderByFields().length * 3));
13557                            }
13558                            else {
13559                                    query = new StringBundler(4);
13560                            }
13561    
13562                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13563    
13564                            query.append(_FINDER_COLUMN_G_L_GROUPID_2);
13565    
13566                            boolean bindLayoutUuid = false;
13567    
13568                            if (layoutUuid == null) {
13569                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
13570                            }
13571                            else if (layoutUuid.equals(StringPool.BLANK)) {
13572                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
13573                            }
13574                            else {
13575                                    bindLayoutUuid = true;
13576    
13577                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
13578                            }
13579    
13580                            if (orderByComparator != null) {
13581                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13582                                            orderByComparator);
13583                            }
13584                            else
13585                             if (pagination) {
13586                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13587                            }
13588    
13589                            String sql = query.toString();
13590    
13591                            Session session = null;
13592    
13593                            try {
13594                                    session = openSession();
13595    
13596                                    Query q = session.createQuery(sql);
13597    
13598                                    QueryPos qPos = QueryPos.getInstance(q);
13599    
13600                                    qPos.add(groupId);
13601    
13602                                    if (bindLayoutUuid) {
13603                                            qPos.add(layoutUuid);
13604                                    }
13605    
13606                                    if (!pagination) {
13607                                            list = (List<JournalArticle>)QueryUtil.list(q,
13608                                                            getDialect(), start, end, false);
13609    
13610                                            Collections.sort(list);
13611    
13612                                            list = new UnmodifiableList<JournalArticle>(list);
13613                                    }
13614                                    else {
13615                                            list = (List<JournalArticle>)QueryUtil.list(q,
13616                                                            getDialect(), start, end);
13617                                    }
13618    
13619                                    cacheResult(list);
13620    
13621                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
13622                            }
13623                            catch (Exception e) {
13624                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13625    
13626                                    throw processException(e);
13627                            }
13628                            finally {
13629                                    closeSession(session);
13630                            }
13631                    }
13632    
13633                    return list;
13634            }
13635    
13636            /**
13637             * Returns the first journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
13638             *
13639             * @param groupId the group ID
13640             * @param layoutUuid the layout uuid
13641             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13642             * @return the first matching journal article
13643             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13644             * @throws SystemException if a system exception occurred
13645             */
13646            @Override
13647            public JournalArticle findByG_L_First(long groupId, String layoutUuid,
13648                    OrderByComparator orderByComparator)
13649                    throws NoSuchArticleException, SystemException {
13650                    JournalArticle journalArticle = fetchByG_L_First(groupId, layoutUuid,
13651                                    orderByComparator);
13652    
13653                    if (journalArticle != null) {
13654                            return journalArticle;
13655                    }
13656    
13657                    StringBundler msg = new StringBundler(6);
13658    
13659                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13660    
13661                    msg.append("groupId=");
13662                    msg.append(groupId);
13663    
13664                    msg.append(", layoutUuid=");
13665                    msg.append(layoutUuid);
13666    
13667                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13668    
13669                    throw new NoSuchArticleException(msg.toString());
13670            }
13671    
13672            /**
13673             * Returns the first journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
13674             *
13675             * @param groupId the group ID
13676             * @param layoutUuid the layout uuid
13677             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13678             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
13679             * @throws SystemException if a system exception occurred
13680             */
13681            @Override
13682            public JournalArticle fetchByG_L_First(long groupId, String layoutUuid,
13683                    OrderByComparator orderByComparator) throws SystemException {
13684                    List<JournalArticle> list = findByG_L(groupId, layoutUuid, 0, 1,
13685                                    orderByComparator);
13686    
13687                    if (!list.isEmpty()) {
13688                            return list.get(0);
13689                    }
13690    
13691                    return null;
13692            }
13693    
13694            /**
13695             * Returns the last journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
13696             *
13697             * @param groupId the group ID
13698             * @param layoutUuid the layout uuid
13699             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13700             * @return the last matching journal article
13701             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13702             * @throws SystemException if a system exception occurred
13703             */
13704            @Override
13705            public JournalArticle findByG_L_Last(long groupId, String layoutUuid,
13706                    OrderByComparator orderByComparator)
13707                    throws NoSuchArticleException, SystemException {
13708                    JournalArticle journalArticle = fetchByG_L_Last(groupId, layoutUuid,
13709                                    orderByComparator);
13710    
13711                    if (journalArticle != null) {
13712                            return journalArticle;
13713                    }
13714    
13715                    StringBundler msg = new StringBundler(6);
13716    
13717                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13718    
13719                    msg.append("groupId=");
13720                    msg.append(groupId);
13721    
13722                    msg.append(", layoutUuid=");
13723                    msg.append(layoutUuid);
13724    
13725                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13726    
13727                    throw new NoSuchArticleException(msg.toString());
13728            }
13729    
13730            /**
13731             * Returns the last journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
13732             *
13733             * @param groupId the group ID
13734             * @param layoutUuid the layout uuid
13735             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13736             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
13737             * @throws SystemException if a system exception occurred
13738             */
13739            @Override
13740            public JournalArticle fetchByG_L_Last(long groupId, String layoutUuid,
13741                    OrderByComparator orderByComparator) throws SystemException {
13742                    int count = countByG_L(groupId, layoutUuid);
13743    
13744                    if (count == 0) {
13745                            return null;
13746                    }
13747    
13748                    List<JournalArticle> list = findByG_L(groupId, layoutUuid, count - 1,
13749                                    count, orderByComparator);
13750    
13751                    if (!list.isEmpty()) {
13752                            return list.get(0);
13753                    }
13754    
13755                    return null;
13756            }
13757    
13758            /**
13759             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
13760             *
13761             * @param id the primary key of the current journal article
13762             * @param groupId the group ID
13763             * @param layoutUuid the layout uuid
13764             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13765             * @return the previous, current, and next journal article
13766             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13767             * @throws SystemException if a system exception occurred
13768             */
13769            @Override
13770            public JournalArticle[] findByG_L_PrevAndNext(long id, long groupId,
13771                    String layoutUuid, OrderByComparator orderByComparator)
13772                    throws NoSuchArticleException, SystemException {
13773                    JournalArticle journalArticle = findByPrimaryKey(id);
13774    
13775                    Session session = null;
13776    
13777                    try {
13778                            session = openSession();
13779    
13780                            JournalArticle[] array = new JournalArticleImpl[3];
13781    
13782                            array[0] = getByG_L_PrevAndNext(session, journalArticle, groupId,
13783                                            layoutUuid, orderByComparator, true);
13784    
13785                            array[1] = journalArticle;
13786    
13787                            array[2] = getByG_L_PrevAndNext(session, journalArticle, groupId,
13788                                            layoutUuid, orderByComparator, false);
13789    
13790                            return array;
13791                    }
13792                    catch (Exception e) {
13793                            throw processException(e);
13794                    }
13795                    finally {
13796                            closeSession(session);
13797                    }
13798            }
13799    
13800            protected JournalArticle getByG_L_PrevAndNext(Session session,
13801                    JournalArticle journalArticle, long groupId, String layoutUuid,
13802                    OrderByComparator orderByComparator, boolean previous) {
13803                    StringBundler query = null;
13804    
13805                    if (orderByComparator != null) {
13806                            query = new StringBundler(6 +
13807                                            (orderByComparator.getOrderByFields().length * 6));
13808                    }
13809                    else {
13810                            query = new StringBundler(3);
13811                    }
13812    
13813                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13814    
13815                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
13816    
13817                    boolean bindLayoutUuid = false;
13818    
13819                    if (layoutUuid == null) {
13820                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
13821                    }
13822                    else if (layoutUuid.equals(StringPool.BLANK)) {
13823                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
13824                    }
13825                    else {
13826                            bindLayoutUuid = true;
13827    
13828                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
13829                    }
13830    
13831                    if (orderByComparator != null) {
13832                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13833    
13834                            if (orderByConditionFields.length > 0) {
13835                                    query.append(WHERE_AND);
13836                            }
13837    
13838                            for (int i = 0; i < orderByConditionFields.length; i++) {
13839                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13840                                    query.append(orderByConditionFields[i]);
13841    
13842                                    if ((i + 1) < orderByConditionFields.length) {
13843                                            if (orderByComparator.isAscending() ^ previous) {
13844                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13845                                            }
13846                                            else {
13847                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13848                                            }
13849                                    }
13850                                    else {
13851                                            if (orderByComparator.isAscending() ^ previous) {
13852                                                    query.append(WHERE_GREATER_THAN);
13853                                            }
13854                                            else {
13855                                                    query.append(WHERE_LESSER_THAN);
13856                                            }
13857                                    }
13858                            }
13859    
13860                            query.append(ORDER_BY_CLAUSE);
13861    
13862                            String[] orderByFields = orderByComparator.getOrderByFields();
13863    
13864                            for (int i = 0; i < orderByFields.length; i++) {
13865                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13866                                    query.append(orderByFields[i]);
13867    
13868                                    if ((i + 1) < orderByFields.length) {
13869                                            if (orderByComparator.isAscending() ^ previous) {
13870                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13871                                            }
13872                                            else {
13873                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13874                                            }
13875                                    }
13876                                    else {
13877                                            if (orderByComparator.isAscending() ^ previous) {
13878                                                    query.append(ORDER_BY_ASC);
13879                                            }
13880                                            else {
13881                                                    query.append(ORDER_BY_DESC);
13882                                            }
13883                                    }
13884                            }
13885                    }
13886                    else {
13887                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13888                    }
13889    
13890                    String sql = query.toString();
13891    
13892                    Query q = session.createQuery(sql);
13893    
13894                    q.setFirstResult(0);
13895                    q.setMaxResults(2);
13896    
13897                    QueryPos qPos = QueryPos.getInstance(q);
13898    
13899                    qPos.add(groupId);
13900    
13901                    if (bindLayoutUuid) {
13902                            qPos.add(layoutUuid);
13903                    }
13904    
13905                    if (orderByComparator != null) {
13906                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13907    
13908                            for (Object value : values) {
13909                                    qPos.add(value);
13910                            }
13911                    }
13912    
13913                    List<JournalArticle> list = q.list();
13914    
13915                    if (list.size() == 2) {
13916                            return list.get(1);
13917                    }
13918                    else {
13919                            return null;
13920                    }
13921            }
13922    
13923            /**
13924             * Returns all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
13925             *
13926             * @param groupId the group ID
13927             * @param layoutUuid the layout uuid
13928             * @return the matching journal articles that the user has permission to view
13929             * @throws SystemException if a system exception occurred
13930             */
13931            @Override
13932            public List<JournalArticle> filterFindByG_L(long groupId, String layoutUuid)
13933                    throws SystemException {
13934                    return filterFindByG_L(groupId, layoutUuid, QueryUtil.ALL_POS,
13935                            QueryUtil.ALL_POS, null);
13936            }
13937    
13938            /**
13939             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
13940             *
13941             * <p>
13942             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13943             * </p>
13944             *
13945             * @param groupId the group ID
13946             * @param layoutUuid the layout uuid
13947             * @param start the lower bound of the range of journal articles
13948             * @param end the upper bound of the range of journal articles (not inclusive)
13949             * @return the range of matching journal articles that the user has permission to view
13950             * @throws SystemException if a system exception occurred
13951             */
13952            @Override
13953            public List<JournalArticle> filterFindByG_L(long groupId,
13954                    String layoutUuid, int start, int end) throws SystemException {
13955                    return filterFindByG_L(groupId, layoutUuid, start, end, null);
13956            }
13957    
13958            /**
13959             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and layoutUuid = &#63;.
13960             *
13961             * <p>
13962             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13963             * </p>
13964             *
13965             * @param groupId the group ID
13966             * @param layoutUuid the layout uuid
13967             * @param start the lower bound of the range of journal articles
13968             * @param end the upper bound of the range of journal articles (not inclusive)
13969             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13970             * @return the ordered range of matching journal articles that the user has permission to view
13971             * @throws SystemException if a system exception occurred
13972             */
13973            @Override
13974            public List<JournalArticle> filterFindByG_L(long groupId,
13975                    String layoutUuid, int start, int end,
13976                    OrderByComparator orderByComparator) throws SystemException {
13977                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13978                            return findByG_L(groupId, layoutUuid, start, end, orderByComparator);
13979                    }
13980    
13981                    StringBundler query = null;
13982    
13983                    if (orderByComparator != null) {
13984                            query = new StringBundler(4 +
13985                                            (orderByComparator.getOrderByFields().length * 3));
13986                    }
13987                    else {
13988                            query = new StringBundler(4);
13989                    }
13990    
13991                    if (getDB().isSupportsInlineDistinct()) {
13992                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
13993                    }
13994                    else {
13995                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
13996                    }
13997    
13998                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
13999    
14000                    boolean bindLayoutUuid = false;
14001    
14002                    if (layoutUuid == null) {
14003                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
14004                    }
14005                    else if (layoutUuid.equals(StringPool.BLANK)) {
14006                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
14007                    }
14008                    else {
14009                            bindLayoutUuid = true;
14010    
14011                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
14012                    }
14013    
14014                    if (!getDB().isSupportsInlineDistinct()) {
14015                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
14016                    }
14017    
14018                    if (orderByComparator != null) {
14019                            if (getDB().isSupportsInlineDistinct()) {
14020                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14021                                            orderByComparator, true);
14022                            }
14023                            else {
14024                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
14025                                            orderByComparator, true);
14026                            }
14027                    }
14028                    else {
14029                            if (getDB().isSupportsInlineDistinct()) {
14030                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14031                            }
14032                            else {
14033                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
14034                            }
14035                    }
14036    
14037                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14038                                    JournalArticle.class.getName(),
14039                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14040    
14041                    Session session = null;
14042    
14043                    try {
14044                            session = openSession();
14045    
14046                            SQLQuery q = session.createSQLQuery(sql);
14047    
14048                            if (getDB().isSupportsInlineDistinct()) {
14049                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
14050                            }
14051                            else {
14052                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
14053                            }
14054    
14055                            QueryPos qPos = QueryPos.getInstance(q);
14056    
14057                            qPos.add(groupId);
14058    
14059                            if (bindLayoutUuid) {
14060                                    qPos.add(layoutUuid);
14061                            }
14062    
14063                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
14064                                    end);
14065                    }
14066                    catch (Exception e) {
14067                            throw processException(e);
14068                    }
14069                    finally {
14070                            closeSession(session);
14071                    }
14072            }
14073    
14074            /**
14075             * 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;.
14076             *
14077             * @param id the primary key of the current journal article
14078             * @param groupId the group ID
14079             * @param layoutUuid the layout uuid
14080             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14081             * @return the previous, current, and next journal article
14082             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
14083             * @throws SystemException if a system exception occurred
14084             */
14085            @Override
14086            public JournalArticle[] filterFindByG_L_PrevAndNext(long id, long groupId,
14087                    String layoutUuid, OrderByComparator orderByComparator)
14088                    throws NoSuchArticleException, SystemException {
14089                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14090                            return findByG_L_PrevAndNext(id, groupId, layoutUuid,
14091                                    orderByComparator);
14092                    }
14093    
14094                    JournalArticle journalArticle = findByPrimaryKey(id);
14095    
14096                    Session session = null;
14097    
14098                    try {
14099                            session = openSession();
14100    
14101                            JournalArticle[] array = new JournalArticleImpl[3];
14102    
14103                            array[0] = filterGetByG_L_PrevAndNext(session, journalArticle,
14104                                            groupId, layoutUuid, orderByComparator, true);
14105    
14106                            array[1] = journalArticle;
14107    
14108                            array[2] = filterGetByG_L_PrevAndNext(session, journalArticle,
14109                                            groupId, layoutUuid, orderByComparator, false);
14110    
14111                            return array;
14112                    }
14113                    catch (Exception e) {
14114                            throw processException(e);
14115                    }
14116                    finally {
14117                            closeSession(session);
14118                    }
14119            }
14120    
14121            protected JournalArticle filterGetByG_L_PrevAndNext(Session session,
14122                    JournalArticle journalArticle, long groupId, String layoutUuid,
14123                    OrderByComparator orderByComparator, boolean previous) {
14124                    StringBundler query = null;
14125    
14126                    if (orderByComparator != null) {
14127                            query = new StringBundler(6 +
14128                                            (orderByComparator.getOrderByFields().length * 6));
14129                    }
14130                    else {
14131                            query = new StringBundler(3);
14132                    }
14133    
14134                    if (getDB().isSupportsInlineDistinct()) {
14135                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
14136                    }
14137                    else {
14138                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
14139                    }
14140    
14141                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
14142    
14143                    boolean bindLayoutUuid = false;
14144    
14145                    if (layoutUuid == null) {
14146                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
14147                    }
14148                    else if (layoutUuid.equals(StringPool.BLANK)) {
14149                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
14150                    }
14151                    else {
14152                            bindLayoutUuid = true;
14153    
14154                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
14155                    }
14156    
14157                    if (!getDB().isSupportsInlineDistinct()) {
14158                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
14159                    }
14160    
14161                    if (orderByComparator != null) {
14162                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14163    
14164                            if (orderByConditionFields.length > 0) {
14165                                    query.append(WHERE_AND);
14166                            }
14167    
14168                            for (int i = 0; i < orderByConditionFields.length; i++) {
14169                                    if (getDB().isSupportsInlineDistinct()) {
14170                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14171                                    }
14172                                    else {
14173                                            query.append(_ORDER_BY_ENTITY_TABLE);
14174                                    }
14175    
14176                                    query.append(orderByConditionFields[i]);
14177    
14178                                    if ((i + 1) < orderByConditionFields.length) {
14179                                            if (orderByComparator.isAscending() ^ previous) {
14180                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14181                                            }
14182                                            else {
14183                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14184                                            }
14185                                    }
14186                                    else {
14187                                            if (orderByComparator.isAscending() ^ previous) {
14188                                                    query.append(WHERE_GREATER_THAN);
14189                                            }
14190                                            else {
14191                                                    query.append(WHERE_LESSER_THAN);
14192                                            }
14193                                    }
14194                            }
14195    
14196                            query.append(ORDER_BY_CLAUSE);
14197    
14198                            String[] orderByFields = orderByComparator.getOrderByFields();
14199    
14200                            for (int i = 0; i < orderByFields.length; i++) {
14201                                    if (getDB().isSupportsInlineDistinct()) {
14202                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14203                                    }
14204                                    else {
14205                                            query.append(_ORDER_BY_ENTITY_TABLE);
14206                                    }
14207    
14208                                    query.append(orderByFields[i]);
14209    
14210                                    if ((i + 1) < orderByFields.length) {
14211                                            if (orderByComparator.isAscending() ^ previous) {
14212                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14213                                            }
14214                                            else {
14215                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14216                                            }
14217                                    }
14218                                    else {
14219                                            if (orderByComparator.isAscending() ^ previous) {
14220                                                    query.append(ORDER_BY_ASC);
14221                                            }
14222                                            else {
14223                                                    query.append(ORDER_BY_DESC);
14224                                            }
14225                                    }
14226                            }
14227                    }
14228                    else {
14229                            if (getDB().isSupportsInlineDistinct()) {
14230                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14231                            }
14232                            else {
14233                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
14234                            }
14235                    }
14236    
14237                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14238                                    JournalArticle.class.getName(),
14239                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14240    
14241                    SQLQuery q = session.createSQLQuery(sql);
14242    
14243                    q.setFirstResult(0);
14244                    q.setMaxResults(2);
14245    
14246                    if (getDB().isSupportsInlineDistinct()) {
14247                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
14248                    }
14249                    else {
14250                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
14251                    }
14252    
14253                    QueryPos qPos = QueryPos.getInstance(q);
14254    
14255                    qPos.add(groupId);
14256    
14257                    if (bindLayoutUuid) {
14258                            qPos.add(layoutUuid);
14259                    }
14260    
14261                    if (orderByComparator != null) {
14262                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
14263    
14264                            for (Object value : values) {
14265                                    qPos.add(value);
14266                            }
14267                    }
14268    
14269                    List<JournalArticle> list = q.list();
14270    
14271                    if (list.size() == 2) {
14272                            return list.get(1);
14273                    }
14274                    else {
14275                            return null;
14276                    }
14277            }
14278    
14279            /**
14280             * Removes all the journal articles where groupId = &#63; and layoutUuid = &#63; from the database.
14281             *
14282             * @param groupId the group ID
14283             * @param layoutUuid the layout uuid
14284             * @throws SystemException if a system exception occurred
14285             */
14286            @Override
14287            public void removeByG_L(long groupId, String layoutUuid)
14288                    throws SystemException {
14289                    for (JournalArticle journalArticle : findByG_L(groupId, layoutUuid,
14290                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14291                            remove(journalArticle);
14292                    }
14293            }
14294    
14295            /**
14296             * Returns the number of journal articles where groupId = &#63; and layoutUuid = &#63;.
14297             *
14298             * @param groupId the group ID
14299             * @param layoutUuid the layout uuid
14300             * @return the number of matching journal articles
14301             * @throws SystemException if a system exception occurred
14302             */
14303            @Override
14304            public int countByG_L(long groupId, String layoutUuid)
14305                    throws SystemException {
14306                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_L;
14307    
14308                    Object[] finderArgs = new Object[] { groupId, layoutUuid };
14309    
14310                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
14311                                    this);
14312    
14313                    if (count == null) {
14314                            StringBundler query = new StringBundler(3);
14315    
14316                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14317    
14318                            query.append(_FINDER_COLUMN_G_L_GROUPID_2);
14319    
14320                            boolean bindLayoutUuid = false;
14321    
14322                            if (layoutUuid == null) {
14323                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
14324                            }
14325                            else if (layoutUuid.equals(StringPool.BLANK)) {
14326                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
14327                            }
14328                            else {
14329                                    bindLayoutUuid = true;
14330    
14331                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
14332                            }
14333    
14334                            String sql = query.toString();
14335    
14336                            Session session = null;
14337    
14338                            try {
14339                                    session = openSession();
14340    
14341                                    Query q = session.createQuery(sql);
14342    
14343                                    QueryPos qPos = QueryPos.getInstance(q);
14344    
14345                                    qPos.add(groupId);
14346    
14347                                    if (bindLayoutUuid) {
14348                                            qPos.add(layoutUuid);
14349                                    }
14350    
14351                                    count = (Long)q.uniqueResult();
14352    
14353                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
14354                            }
14355                            catch (Exception e) {
14356                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14357    
14358                                    throw processException(e);
14359                            }
14360                            finally {
14361                                    closeSession(session);
14362                            }
14363                    }
14364    
14365                    return count.intValue();
14366            }
14367    
14368            /**
14369             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
14370             *
14371             * @param groupId the group ID
14372             * @param layoutUuid the layout uuid
14373             * @return the number of matching journal articles that the user has permission to view
14374             * @throws SystemException if a system exception occurred
14375             */
14376            @Override
14377            public int filterCountByG_L(long groupId, String layoutUuid)
14378                    throws SystemException {
14379                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14380                            return countByG_L(groupId, layoutUuid);
14381                    }
14382    
14383                    StringBundler query = new StringBundler(3);
14384    
14385                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
14386    
14387                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
14388    
14389                    boolean bindLayoutUuid = false;
14390    
14391                    if (layoutUuid == null) {
14392                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
14393                    }
14394                    else if (layoutUuid.equals(StringPool.BLANK)) {
14395                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
14396                    }
14397                    else {
14398                            bindLayoutUuid = true;
14399    
14400                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
14401                    }
14402    
14403                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14404                                    JournalArticle.class.getName(),
14405                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14406    
14407                    Session session = null;
14408    
14409                    try {
14410                            session = openSession();
14411    
14412                            SQLQuery q = session.createSQLQuery(sql);
14413    
14414                            q.addScalar(COUNT_COLUMN_NAME,
14415                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
14416    
14417                            QueryPos qPos = QueryPos.getInstance(q);
14418    
14419                            qPos.add(groupId);
14420    
14421                            if (bindLayoutUuid) {
14422                                    qPos.add(layoutUuid);
14423                            }
14424    
14425                            Long count = (Long)q.uniqueResult();
14426    
14427                            return count.intValue();
14428                    }
14429                    catch (Exception e) {
14430                            throw processException(e);
14431                    }
14432                    finally {
14433                            closeSession(session);
14434                    }
14435            }
14436    
14437            private static final String _FINDER_COLUMN_G_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
14438            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
14439            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
14440            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = '')";
14441            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14442                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
14443                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
14444                            "findByG_ST",
14445                            new String[] {
14446                                    Long.class.getName(), Integer.class.getName(),
14447                                    
14448                            Integer.class.getName(), Integer.class.getName(),
14449                                    OrderByComparator.class.getName()
14450                            });
14451            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14452                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
14453                            JournalArticleImpl.class,
14454                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_ST",
14455                            new String[] { Long.class.getName(), Integer.class.getName() },
14456                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
14457                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
14458                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
14459                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
14460            public static final FinderPath FINDER_PATH_COUNT_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14461                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
14462                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_ST",
14463                            new String[] { Long.class.getName(), Integer.class.getName() });
14464    
14465            /**
14466             * Returns all the journal articles where groupId = &#63; and status = &#63;.
14467             *
14468             * @param groupId the group ID
14469             * @param status the status
14470             * @return the matching journal articles
14471             * @throws SystemException if a system exception occurred
14472             */
14473            @Override
14474            public List<JournalArticle> findByG_ST(long groupId, int status)
14475                    throws SystemException {
14476                    return findByG_ST(groupId, status, QueryUtil.ALL_POS,
14477                            QueryUtil.ALL_POS, null);
14478            }
14479    
14480            /**
14481             * Returns a range of all the journal articles where groupId = &#63; and status = &#63;.
14482             *
14483             * <p>
14484             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14485             * </p>
14486             *
14487             * @param groupId the group ID
14488             * @param status the status
14489             * @param start the lower bound of the range of journal articles
14490             * @param end the upper bound of the range of journal articles (not inclusive)
14491             * @return the range of matching journal articles
14492             * @throws SystemException if a system exception occurred
14493             */
14494            @Override
14495            public List<JournalArticle> findByG_ST(long groupId, int status, int start,
14496                    int end) throws SystemException {
14497                    return findByG_ST(groupId, status, start, end, null);
14498            }
14499    
14500            /**
14501             * Returns an ordered range of all the journal articles where groupId = &#63; and status = &#63;.
14502             *
14503             * <p>
14504             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14505             * </p>
14506             *
14507             * @param groupId the group ID
14508             * @param status the status
14509             * @param start the lower bound of the range of journal articles
14510             * @param end the upper bound of the range of journal articles (not inclusive)
14511             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14512             * @return the ordered range of matching journal articles
14513             * @throws SystemException if a system exception occurred
14514             */
14515            @Override
14516            public List<JournalArticle> findByG_ST(long groupId, int status, int start,
14517                    int end, OrderByComparator orderByComparator) throws SystemException {
14518                    boolean pagination = true;
14519                    FinderPath finderPath = null;
14520                    Object[] finderArgs = null;
14521    
14522                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
14523                                    (orderByComparator == null)) {
14524                            pagination = false;
14525                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST;
14526                            finderArgs = new Object[] { groupId, status };
14527                    }
14528                    else {
14529                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_ST;
14530                            finderArgs = new Object[] {
14531                                            groupId, status,
14532                                            
14533                                            start, end, orderByComparator
14534                                    };
14535                    }
14536    
14537                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
14538                                    finderArgs, this);
14539    
14540                    if ((list != null) && !list.isEmpty()) {
14541                            for (JournalArticle journalArticle : list) {
14542                                    if ((groupId != journalArticle.getGroupId()) ||
14543                                                    (status != journalArticle.getStatus())) {
14544                                            list = null;
14545    
14546                                            break;
14547                                    }
14548                            }
14549                    }
14550    
14551                    if (list == null) {
14552                            StringBundler query = null;
14553    
14554                            if (orderByComparator != null) {
14555                                    query = new StringBundler(4 +
14556                                                    (orderByComparator.getOrderByFields().length * 3));
14557                            }
14558                            else {
14559                                    query = new StringBundler(4);
14560                            }
14561    
14562                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
14563    
14564                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
14565    
14566                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
14567    
14568                            if (orderByComparator != null) {
14569                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14570                                            orderByComparator);
14571                            }
14572                            else
14573                             if (pagination) {
14574                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14575                            }
14576    
14577                            String sql = query.toString();
14578    
14579                            Session session = null;
14580    
14581                            try {
14582                                    session = openSession();
14583    
14584                                    Query q = session.createQuery(sql);
14585    
14586                                    QueryPos qPos = QueryPos.getInstance(q);
14587    
14588                                    qPos.add(groupId);
14589    
14590                                    qPos.add(status);
14591    
14592                                    if (!pagination) {
14593                                            list = (List<JournalArticle>)QueryUtil.list(q,
14594                                                            getDialect(), start, end, false);
14595    
14596                                            Collections.sort(list);
14597    
14598                                            list = new UnmodifiableList<JournalArticle>(list);
14599                                    }
14600                                    else {
14601                                            list = (List<JournalArticle>)QueryUtil.list(q,
14602                                                            getDialect(), start, end);
14603                                    }
14604    
14605                                    cacheResult(list);
14606    
14607                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
14608                            }
14609                            catch (Exception e) {
14610                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14611    
14612                                    throw processException(e);
14613                            }
14614                            finally {
14615                                    closeSession(session);
14616                            }
14617                    }
14618    
14619                    return list;
14620            }
14621    
14622            /**
14623             * Returns the first journal article in the ordered set where groupId = &#63; and status = &#63;.
14624             *
14625             * @param groupId the group ID
14626             * @param status the status
14627             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14628             * @return the first matching journal article
14629             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
14630             * @throws SystemException if a system exception occurred
14631             */
14632            @Override
14633            public JournalArticle findByG_ST_First(long groupId, int status,
14634                    OrderByComparator orderByComparator)
14635                    throws NoSuchArticleException, SystemException {
14636                    JournalArticle journalArticle = fetchByG_ST_First(groupId, status,
14637                                    orderByComparator);
14638    
14639                    if (journalArticle != null) {
14640                            return journalArticle;
14641                    }
14642    
14643                    StringBundler msg = new StringBundler(6);
14644    
14645                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14646    
14647                    msg.append("groupId=");
14648                    msg.append(groupId);
14649    
14650                    msg.append(", status=");
14651                    msg.append(status);
14652    
14653                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14654    
14655                    throw new NoSuchArticleException(msg.toString());
14656            }
14657    
14658            /**
14659             * Returns the first journal article in the ordered set where groupId = &#63; and status = &#63;.
14660             *
14661             * @param groupId the group ID
14662             * @param status the status
14663             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14664             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
14665             * @throws SystemException if a system exception occurred
14666             */
14667            @Override
14668            public JournalArticle fetchByG_ST_First(long groupId, int status,
14669                    OrderByComparator orderByComparator) throws SystemException {
14670                    List<JournalArticle> list = findByG_ST(groupId, status, 0, 1,
14671                                    orderByComparator);
14672    
14673                    if (!list.isEmpty()) {
14674                            return list.get(0);
14675                    }
14676    
14677                    return null;
14678            }
14679    
14680            /**
14681             * Returns the last journal article in the ordered set where groupId = &#63; and status = &#63;.
14682             *
14683             * @param groupId the group ID
14684             * @param status the status
14685             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14686             * @return the last matching journal article
14687             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
14688             * @throws SystemException if a system exception occurred
14689             */
14690            @Override
14691            public JournalArticle findByG_ST_Last(long groupId, int status,
14692                    OrderByComparator orderByComparator)
14693                    throws NoSuchArticleException, SystemException {
14694                    JournalArticle journalArticle = fetchByG_ST_Last(groupId, status,
14695                                    orderByComparator);
14696    
14697                    if (journalArticle != null) {
14698                            return journalArticle;
14699                    }
14700    
14701                    StringBundler msg = new StringBundler(6);
14702    
14703                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14704    
14705                    msg.append("groupId=");
14706                    msg.append(groupId);
14707    
14708                    msg.append(", status=");
14709                    msg.append(status);
14710    
14711                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14712    
14713                    throw new NoSuchArticleException(msg.toString());
14714            }
14715    
14716            /**
14717             * Returns the last journal article in the ordered set where groupId = &#63; and status = &#63;.
14718             *
14719             * @param groupId the group ID
14720             * @param status the status
14721             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14722             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
14723             * @throws SystemException if a system exception occurred
14724             */
14725            @Override
14726            public JournalArticle fetchByG_ST_Last(long groupId, int status,
14727                    OrderByComparator orderByComparator) throws SystemException {
14728                    int count = countByG_ST(groupId, status);
14729    
14730                    if (count == 0) {
14731                            return null;
14732                    }
14733    
14734                    List<JournalArticle> list = findByG_ST(groupId, status, count - 1,
14735                                    count, orderByComparator);
14736    
14737                    if (!list.isEmpty()) {
14738                            return list.get(0);
14739                    }
14740    
14741                    return null;
14742            }
14743    
14744            /**
14745             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and status = &#63;.
14746             *
14747             * @param id the primary key of the current journal article
14748             * @param groupId the group ID
14749             * @param status the status
14750             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14751             * @return the previous, current, and next journal article
14752             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
14753             * @throws SystemException if a system exception occurred
14754             */
14755            @Override
14756            public JournalArticle[] findByG_ST_PrevAndNext(long id, long groupId,
14757                    int status, OrderByComparator orderByComparator)
14758                    throws NoSuchArticleException, SystemException {
14759                    JournalArticle journalArticle = findByPrimaryKey(id);
14760    
14761                    Session session = null;
14762    
14763                    try {
14764                            session = openSession();
14765    
14766                            JournalArticle[] array = new JournalArticleImpl[3];
14767    
14768                            array[0] = getByG_ST_PrevAndNext(session, journalArticle, groupId,
14769                                            status, orderByComparator, true);
14770    
14771                            array[1] = journalArticle;
14772    
14773                            array[2] = getByG_ST_PrevAndNext(session, journalArticle, groupId,
14774                                            status, orderByComparator, false);
14775    
14776                            return array;
14777                    }
14778                    catch (Exception e) {
14779                            throw processException(e);
14780                    }
14781                    finally {
14782                            closeSession(session);
14783                    }
14784            }
14785    
14786            protected JournalArticle getByG_ST_PrevAndNext(Session session,
14787                    JournalArticle journalArticle, long groupId, int status,
14788                    OrderByComparator orderByComparator, boolean previous) {
14789                    StringBundler query = null;
14790    
14791                    if (orderByComparator != null) {
14792                            query = new StringBundler(6 +
14793                                            (orderByComparator.getOrderByFields().length * 6));
14794                    }
14795                    else {
14796                            query = new StringBundler(3);
14797                    }
14798    
14799                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
14800    
14801                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
14802    
14803                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
14804    
14805                    if (orderByComparator != null) {
14806                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14807    
14808                            if (orderByConditionFields.length > 0) {
14809                                    query.append(WHERE_AND);
14810                            }
14811    
14812                            for (int i = 0; i < orderByConditionFields.length; i++) {
14813                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14814                                    query.append(orderByConditionFields[i]);
14815    
14816                                    if ((i + 1) < orderByConditionFields.length) {
14817                                            if (orderByComparator.isAscending() ^ previous) {
14818                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14819                                            }
14820                                            else {
14821                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14822                                            }
14823                                    }
14824                                    else {
14825                                            if (orderByComparator.isAscending() ^ previous) {
14826                                                    query.append(WHERE_GREATER_THAN);
14827                                            }
14828                                            else {
14829                                                    query.append(WHERE_LESSER_THAN);
14830                                            }
14831                                    }
14832                            }
14833    
14834                            query.append(ORDER_BY_CLAUSE);
14835    
14836                            String[] orderByFields = orderByComparator.getOrderByFields();
14837    
14838                            for (int i = 0; i < orderByFields.length; i++) {
14839                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14840                                    query.append(orderByFields[i]);
14841    
14842                                    if ((i + 1) < orderByFields.length) {
14843                                            if (orderByComparator.isAscending() ^ previous) {
14844                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14845                                            }
14846                                            else {
14847                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14848                                            }
14849                                    }
14850                                    else {
14851                                            if (orderByComparator.isAscending() ^ previous) {
14852                                                    query.append(ORDER_BY_ASC);
14853                                            }
14854                                            else {
14855                                                    query.append(ORDER_BY_DESC);
14856                                            }
14857                                    }
14858                            }
14859                    }
14860                    else {
14861                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14862                    }
14863    
14864                    String sql = query.toString();
14865    
14866                    Query q = session.createQuery(sql);
14867    
14868                    q.setFirstResult(0);
14869                    q.setMaxResults(2);
14870    
14871                    QueryPos qPos = QueryPos.getInstance(q);
14872    
14873                    qPos.add(groupId);
14874    
14875                    qPos.add(status);
14876    
14877                    if (orderByComparator != null) {
14878                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
14879    
14880                            for (Object value : values) {
14881                                    qPos.add(value);
14882                            }
14883                    }
14884    
14885                    List<JournalArticle> list = q.list();
14886    
14887                    if (list.size() == 2) {
14888                            return list.get(1);
14889                    }
14890                    else {
14891                            return null;
14892                    }
14893            }
14894    
14895            /**
14896             * Returns all the journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
14897             *
14898             * @param groupId the group ID
14899             * @param status the status
14900             * @return the matching journal articles that the user has permission to view
14901             * @throws SystemException if a system exception occurred
14902             */
14903            @Override
14904            public List<JournalArticle> filterFindByG_ST(long groupId, int status)
14905                    throws SystemException {
14906                    return filterFindByG_ST(groupId, status, QueryUtil.ALL_POS,
14907                            QueryUtil.ALL_POS, null);
14908            }
14909    
14910            /**
14911             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
14912             *
14913             * <p>
14914             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14915             * </p>
14916             *
14917             * @param groupId the group ID
14918             * @param status the status
14919             * @param start the lower bound of the range of journal articles
14920             * @param end the upper bound of the range of journal articles (not inclusive)
14921             * @return the range of matching journal articles that the user has permission to view
14922             * @throws SystemException if a system exception occurred
14923             */
14924            @Override
14925            public List<JournalArticle> filterFindByG_ST(long groupId, int status,
14926                    int start, int end) throws SystemException {
14927                    return filterFindByG_ST(groupId, status, start, end, null);
14928            }
14929    
14930            /**
14931             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and status = &#63;.
14932             *
14933             * <p>
14934             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14935             * </p>
14936             *
14937             * @param groupId the group ID
14938             * @param status the status
14939             * @param start the lower bound of the range of journal articles
14940             * @param end the upper bound of the range of journal articles (not inclusive)
14941             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14942             * @return the ordered range of matching journal articles that the user has permission to view
14943             * @throws SystemException if a system exception occurred
14944             */
14945            @Override
14946            public List<JournalArticle> filterFindByG_ST(long groupId, int status,
14947                    int start, int end, OrderByComparator orderByComparator)
14948                    throws SystemException {
14949                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14950                            return findByG_ST(groupId, status, start, end, orderByComparator);
14951                    }
14952    
14953                    StringBundler query = null;
14954    
14955                    if (orderByComparator != null) {
14956                            query = new StringBundler(4 +
14957                                            (orderByComparator.getOrderByFields().length * 3));
14958                    }
14959                    else {
14960                            query = new StringBundler(4);
14961                    }
14962    
14963                    if (getDB().isSupportsInlineDistinct()) {
14964                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
14965                    }
14966                    else {
14967                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
14968                    }
14969    
14970                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
14971    
14972                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
14973    
14974                    if (!getDB().isSupportsInlineDistinct()) {
14975                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
14976                    }
14977    
14978                    if (orderByComparator != null) {
14979                            if (getDB().isSupportsInlineDistinct()) {
14980                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14981                                            orderByComparator, true);
14982                            }
14983                            else {
14984                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
14985                                            orderByComparator, true);
14986                            }
14987                    }
14988                    else {
14989                            if (getDB().isSupportsInlineDistinct()) {
14990                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14991                            }
14992                            else {
14993                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
14994                            }
14995                    }
14996    
14997                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14998                                    JournalArticle.class.getName(),
14999                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15000    
15001                    Session session = null;
15002    
15003                    try {
15004                            session = openSession();
15005    
15006                            SQLQuery q = session.createSQLQuery(sql);
15007    
15008                            if (getDB().isSupportsInlineDistinct()) {
15009                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
15010                            }
15011                            else {
15012                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
15013                            }
15014    
15015                            QueryPos qPos = QueryPos.getInstance(q);
15016    
15017                            qPos.add(groupId);
15018    
15019                            qPos.add(status);
15020    
15021                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
15022                                    end);
15023                    }
15024                    catch (Exception e) {
15025                            throw processException(e);
15026                    }
15027                    finally {
15028                            closeSession(session);
15029                    }
15030            }
15031    
15032            /**
15033             * 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;.
15034             *
15035             * @param id the primary key of the current journal article
15036             * @param groupId the group ID
15037             * @param status the status
15038             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15039             * @return the previous, current, and next journal article
15040             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
15041             * @throws SystemException if a system exception occurred
15042             */
15043            @Override
15044            public JournalArticle[] filterFindByG_ST_PrevAndNext(long id, long groupId,
15045                    int status, OrderByComparator orderByComparator)
15046                    throws NoSuchArticleException, SystemException {
15047                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15048                            return findByG_ST_PrevAndNext(id, groupId, status, orderByComparator);
15049                    }
15050    
15051                    JournalArticle journalArticle = findByPrimaryKey(id);
15052    
15053                    Session session = null;
15054    
15055                    try {
15056                            session = openSession();
15057    
15058                            JournalArticle[] array = new JournalArticleImpl[3];
15059    
15060                            array[0] = filterGetByG_ST_PrevAndNext(session, journalArticle,
15061                                            groupId, status, orderByComparator, true);
15062    
15063                            array[1] = journalArticle;
15064    
15065                            array[2] = filterGetByG_ST_PrevAndNext(session, journalArticle,
15066                                            groupId, status, orderByComparator, false);
15067    
15068                            return array;
15069                    }
15070                    catch (Exception e) {
15071                            throw processException(e);
15072                    }
15073                    finally {
15074                            closeSession(session);
15075                    }
15076            }
15077    
15078            protected JournalArticle filterGetByG_ST_PrevAndNext(Session session,
15079                    JournalArticle journalArticle, long groupId, int status,
15080                    OrderByComparator orderByComparator, boolean previous) {
15081                    StringBundler query = null;
15082    
15083                    if (orderByComparator != null) {
15084                            query = new StringBundler(6 +
15085                                            (orderByComparator.getOrderByFields().length * 6));
15086                    }
15087                    else {
15088                            query = new StringBundler(3);
15089                    }
15090    
15091                    if (getDB().isSupportsInlineDistinct()) {
15092                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
15093                    }
15094                    else {
15095                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
15096                    }
15097    
15098                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
15099    
15100                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
15101    
15102                    if (!getDB().isSupportsInlineDistinct()) {
15103                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
15104                    }
15105    
15106                    if (orderByComparator != null) {
15107                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15108    
15109                            if (orderByConditionFields.length > 0) {
15110                                    query.append(WHERE_AND);
15111                            }
15112    
15113                            for (int i = 0; i < orderByConditionFields.length; i++) {
15114                                    if (getDB().isSupportsInlineDistinct()) {
15115                                            query.append(_ORDER_BY_ENTITY_ALIAS);
15116                                    }
15117                                    else {
15118                                            query.append(_ORDER_BY_ENTITY_TABLE);
15119                                    }
15120    
15121                                    query.append(orderByConditionFields[i]);
15122    
15123                                    if ((i + 1) < orderByConditionFields.length) {
15124                                            if (orderByComparator.isAscending() ^ previous) {
15125                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15126                                            }
15127                                            else {
15128                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15129                                            }
15130                                    }
15131                                    else {
15132                                            if (orderByComparator.isAscending() ^ previous) {
15133                                                    query.append(WHERE_GREATER_THAN);
15134                                            }
15135                                            else {
15136                                                    query.append(WHERE_LESSER_THAN);
15137                                            }
15138                                    }
15139                            }
15140    
15141                            query.append(ORDER_BY_CLAUSE);
15142    
15143                            String[] orderByFields = orderByComparator.getOrderByFields();
15144    
15145                            for (int i = 0; i < orderByFields.length; i++) {
15146                                    if (getDB().isSupportsInlineDistinct()) {
15147                                            query.append(_ORDER_BY_ENTITY_ALIAS);
15148                                    }
15149                                    else {
15150                                            query.append(_ORDER_BY_ENTITY_TABLE);
15151                                    }
15152    
15153                                    query.append(orderByFields[i]);
15154    
15155                                    if ((i + 1) < orderByFields.length) {
15156                                            if (orderByComparator.isAscending() ^ previous) {
15157                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15158                                            }
15159                                            else {
15160                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15161                                            }
15162                                    }
15163                                    else {
15164                                            if (orderByComparator.isAscending() ^ previous) {
15165                                                    query.append(ORDER_BY_ASC);
15166                                            }
15167                                            else {
15168                                                    query.append(ORDER_BY_DESC);
15169                                            }
15170                                    }
15171                            }
15172                    }
15173                    else {
15174                            if (getDB().isSupportsInlineDistinct()) {
15175                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15176                            }
15177                            else {
15178                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
15179                            }
15180                    }
15181    
15182                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15183                                    JournalArticle.class.getName(),
15184                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15185    
15186                    SQLQuery q = session.createSQLQuery(sql);
15187    
15188                    q.setFirstResult(0);
15189                    q.setMaxResults(2);
15190    
15191                    if (getDB().isSupportsInlineDistinct()) {
15192                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
15193                    }
15194                    else {
15195                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
15196                    }
15197    
15198                    QueryPos qPos = QueryPos.getInstance(q);
15199    
15200                    qPos.add(groupId);
15201    
15202                    qPos.add(status);
15203    
15204                    if (orderByComparator != null) {
15205                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
15206    
15207                            for (Object value : values) {
15208                                    qPos.add(value);
15209                            }
15210                    }
15211    
15212                    List<JournalArticle> list = q.list();
15213    
15214                    if (list.size() == 2) {
15215                            return list.get(1);
15216                    }
15217                    else {
15218                            return null;
15219                    }
15220            }
15221    
15222            /**
15223             * Removes all the journal articles where groupId = &#63; and status = &#63; from the database.
15224             *
15225             * @param groupId the group ID
15226             * @param status the status
15227             * @throws SystemException if a system exception occurred
15228             */
15229            @Override
15230            public void removeByG_ST(long groupId, int status)
15231                    throws SystemException {
15232                    for (JournalArticle journalArticle : findByG_ST(groupId, status,
15233                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15234                            remove(journalArticle);
15235                    }
15236            }
15237    
15238            /**
15239             * Returns the number of journal articles where groupId = &#63; and status = &#63;.
15240             *
15241             * @param groupId the group ID
15242             * @param status the status
15243             * @return the number of matching journal articles
15244             * @throws SystemException if a system exception occurred
15245             */
15246            @Override
15247            public int countByG_ST(long groupId, int status) throws SystemException {
15248                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_ST;
15249    
15250                    Object[] finderArgs = new Object[] { groupId, status };
15251    
15252                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
15253                                    this);
15254    
15255                    if (count == null) {
15256                            StringBundler query = new StringBundler(3);
15257    
15258                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15259    
15260                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
15261    
15262                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
15263    
15264                            String sql = query.toString();
15265    
15266                            Session session = null;
15267    
15268                            try {
15269                                    session = openSession();
15270    
15271                                    Query q = session.createQuery(sql);
15272    
15273                                    QueryPos qPos = QueryPos.getInstance(q);
15274    
15275                                    qPos.add(groupId);
15276    
15277                                    qPos.add(status);
15278    
15279                                    count = (Long)q.uniqueResult();
15280    
15281                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
15282                            }
15283                            catch (Exception e) {
15284                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15285    
15286                                    throw processException(e);
15287                            }
15288                            finally {
15289                                    closeSession(session);
15290                            }
15291                    }
15292    
15293                    return count.intValue();
15294            }
15295    
15296            /**
15297             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
15298             *
15299             * @param groupId the group ID
15300             * @param status the status
15301             * @return the number of matching journal articles that the user has permission to view
15302             * @throws SystemException if a system exception occurred
15303             */
15304            @Override
15305            public int filterCountByG_ST(long groupId, int status)
15306                    throws SystemException {
15307                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15308                            return countByG_ST(groupId, status);
15309                    }
15310    
15311                    StringBundler query = new StringBundler(3);
15312    
15313                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
15314    
15315                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
15316    
15317                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
15318    
15319                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15320                                    JournalArticle.class.getName(),
15321                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15322    
15323                    Session session = null;
15324    
15325                    try {
15326                            session = openSession();
15327    
15328                            SQLQuery q = session.createSQLQuery(sql);
15329    
15330                            q.addScalar(COUNT_COLUMN_NAME,
15331                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
15332    
15333                            QueryPos qPos = QueryPos.getInstance(q);
15334    
15335                            qPos.add(groupId);
15336    
15337                            qPos.add(status);
15338    
15339                            Long count = (Long)q.uniqueResult();
15340    
15341                            return count.intValue();
15342                    }
15343                    catch (Exception e) {
15344                            throw processException(e);
15345                    }
15346                    finally {
15347                            closeSession(session);
15348                    }
15349            }
15350    
15351            private static final String _FINDER_COLUMN_G_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
15352            private static final String _FINDER_COLUMN_G_ST_STATUS_2 = "journalArticle.status = ?";
15353            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15354                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
15355                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
15356                            "findByC_V",
15357                            new String[] {
15358                                    Long.class.getName(), Double.class.getName(),
15359                                    
15360                            Integer.class.getName(), Integer.class.getName(),
15361                                    OrderByComparator.class.getName()
15362                            });
15363            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15364                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
15365                            JournalArticleImpl.class,
15366                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_V",
15367                            new String[] { Long.class.getName(), Double.class.getName() },
15368                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
15369                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK |
15370                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK);
15371            public static final FinderPath FINDER_PATH_COUNT_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15372                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
15373                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_V",
15374                            new String[] { Long.class.getName(), Double.class.getName() });
15375    
15376            /**
15377             * Returns all the journal articles where companyId = &#63; and version = &#63;.
15378             *
15379             * @param companyId the company ID
15380             * @param version the version
15381             * @return the matching journal articles
15382             * @throws SystemException if a system exception occurred
15383             */
15384            @Override
15385            public List<JournalArticle> findByC_V(long companyId, double version)
15386                    throws SystemException {
15387                    return findByC_V(companyId, version, QueryUtil.ALL_POS,
15388                            QueryUtil.ALL_POS, null);
15389            }
15390    
15391            /**
15392             * Returns a range of all the journal articles where companyId = &#63; and version = &#63;.
15393             *
15394             * <p>
15395             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15396             * </p>
15397             *
15398             * @param companyId the company ID
15399             * @param version the version
15400             * @param start the lower bound of the range of journal articles
15401             * @param end the upper bound of the range of journal articles (not inclusive)
15402             * @return the range of matching journal articles
15403             * @throws SystemException if a system exception occurred
15404             */
15405            @Override
15406            public List<JournalArticle> findByC_V(long companyId, double version,
15407                    int start, int end) throws SystemException {
15408                    return findByC_V(companyId, version, start, end, null);
15409            }
15410    
15411            /**
15412             * Returns an ordered range of all the journal articles where companyId = &#63; and version = &#63;.
15413             *
15414             * <p>
15415             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15416             * </p>
15417             *
15418             * @param companyId the company ID
15419             * @param version the version
15420             * @param start the lower bound of the range of journal articles
15421             * @param end the upper bound of the range of journal articles (not inclusive)
15422             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15423             * @return the ordered range of matching journal articles
15424             * @throws SystemException if a system exception occurred
15425             */
15426            @Override
15427            public List<JournalArticle> findByC_V(long companyId, double version,
15428                    int start, int end, OrderByComparator orderByComparator)
15429                    throws SystemException {
15430                    boolean pagination = true;
15431                    FinderPath finderPath = null;
15432                    Object[] finderArgs = null;
15433    
15434                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
15435                                    (orderByComparator == null)) {
15436                            pagination = false;
15437                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V;
15438                            finderArgs = new Object[] { companyId, version };
15439                    }
15440                    else {
15441                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V;
15442                            finderArgs = new Object[] {
15443                                            companyId, version,
15444                                            
15445                                            start, end, orderByComparator
15446                                    };
15447                    }
15448    
15449                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
15450                                    finderArgs, this);
15451    
15452                    if ((list != null) && !list.isEmpty()) {
15453                            for (JournalArticle journalArticle : list) {
15454                                    if ((companyId != journalArticle.getCompanyId()) ||
15455                                                    (version != journalArticle.getVersion())) {
15456                                            list = null;
15457    
15458                                            break;
15459                                    }
15460                            }
15461                    }
15462    
15463                    if (list == null) {
15464                            StringBundler query = null;
15465    
15466                            if (orderByComparator != null) {
15467                                    query = new StringBundler(4 +
15468                                                    (orderByComparator.getOrderByFields().length * 3));
15469                            }
15470                            else {
15471                                    query = new StringBundler(4);
15472                            }
15473    
15474                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15475    
15476                            query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
15477    
15478                            query.append(_FINDER_COLUMN_C_V_VERSION_2);
15479    
15480                            if (orderByComparator != null) {
15481                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15482                                            orderByComparator);
15483                            }
15484                            else
15485                             if (pagination) {
15486                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15487                            }
15488    
15489                            String sql = query.toString();
15490    
15491                            Session session = null;
15492    
15493                            try {
15494                                    session = openSession();
15495    
15496                                    Query q = session.createQuery(sql);
15497    
15498                                    QueryPos qPos = QueryPos.getInstance(q);
15499    
15500                                    qPos.add(companyId);
15501    
15502                                    qPos.add(version);
15503    
15504                                    if (!pagination) {
15505                                            list = (List<JournalArticle>)QueryUtil.list(q,
15506                                                            getDialect(), start, end, false);
15507    
15508                                            Collections.sort(list);
15509    
15510                                            list = new UnmodifiableList<JournalArticle>(list);
15511                                    }
15512                                    else {
15513                                            list = (List<JournalArticle>)QueryUtil.list(q,
15514                                                            getDialect(), start, end);
15515                                    }
15516    
15517                                    cacheResult(list);
15518    
15519                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
15520                            }
15521                            catch (Exception e) {
15522                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15523    
15524                                    throw processException(e);
15525                            }
15526                            finally {
15527                                    closeSession(session);
15528                            }
15529                    }
15530    
15531                    return list;
15532            }
15533    
15534            /**
15535             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63;.
15536             *
15537             * @param companyId the company ID
15538             * @param version the version
15539             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15540             * @return the first matching journal article
15541             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15542             * @throws SystemException if a system exception occurred
15543             */
15544            @Override
15545            public JournalArticle findByC_V_First(long companyId, double version,
15546                    OrderByComparator orderByComparator)
15547                    throws NoSuchArticleException, SystemException {
15548                    JournalArticle journalArticle = fetchByC_V_First(companyId, version,
15549                                    orderByComparator);
15550    
15551                    if (journalArticle != null) {
15552                            return journalArticle;
15553                    }
15554    
15555                    StringBundler msg = new StringBundler(6);
15556    
15557                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15558    
15559                    msg.append("companyId=");
15560                    msg.append(companyId);
15561    
15562                    msg.append(", version=");
15563                    msg.append(version);
15564    
15565                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15566    
15567                    throw new NoSuchArticleException(msg.toString());
15568            }
15569    
15570            /**
15571             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63;.
15572             *
15573             * @param companyId the company ID
15574             * @param version the version
15575             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15576             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
15577             * @throws SystemException if a system exception occurred
15578             */
15579            @Override
15580            public JournalArticle fetchByC_V_First(long companyId, double version,
15581                    OrderByComparator orderByComparator) throws SystemException {
15582                    List<JournalArticle> list = findByC_V(companyId, version, 0, 1,
15583                                    orderByComparator);
15584    
15585                    if (!list.isEmpty()) {
15586                            return list.get(0);
15587                    }
15588    
15589                    return null;
15590            }
15591    
15592            /**
15593             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63;.
15594             *
15595             * @param companyId the company ID
15596             * @param version the version
15597             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15598             * @return the last matching journal article
15599             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15600             * @throws SystemException if a system exception occurred
15601             */
15602            @Override
15603            public JournalArticle findByC_V_Last(long companyId, double version,
15604                    OrderByComparator orderByComparator)
15605                    throws NoSuchArticleException, SystemException {
15606                    JournalArticle journalArticle = fetchByC_V_Last(companyId, version,
15607                                    orderByComparator);
15608    
15609                    if (journalArticle != null) {
15610                            return journalArticle;
15611                    }
15612    
15613                    StringBundler msg = new StringBundler(6);
15614    
15615                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15616    
15617                    msg.append("companyId=");
15618                    msg.append(companyId);
15619    
15620                    msg.append(", version=");
15621                    msg.append(version);
15622    
15623                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15624    
15625                    throw new NoSuchArticleException(msg.toString());
15626            }
15627    
15628            /**
15629             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63;.
15630             *
15631             * @param companyId the company ID
15632             * @param version the version
15633             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15634             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
15635             * @throws SystemException if a system exception occurred
15636             */
15637            @Override
15638            public JournalArticle fetchByC_V_Last(long companyId, double version,
15639                    OrderByComparator orderByComparator) throws SystemException {
15640                    int count = countByC_V(companyId, version);
15641    
15642                    if (count == 0) {
15643                            return null;
15644                    }
15645    
15646                    List<JournalArticle> list = findByC_V(companyId, version, count - 1,
15647                                    count, orderByComparator);
15648    
15649                    if (!list.isEmpty()) {
15650                            return list.get(0);
15651                    }
15652    
15653                    return null;
15654            }
15655    
15656            /**
15657             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and version = &#63;.
15658             *
15659             * @param id the primary key of the current journal article
15660             * @param companyId the company ID
15661             * @param version the version
15662             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15663             * @return the previous, current, and next journal article
15664             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
15665             * @throws SystemException if a system exception occurred
15666             */
15667            @Override
15668            public JournalArticle[] findByC_V_PrevAndNext(long id, long companyId,
15669                    double version, OrderByComparator orderByComparator)
15670                    throws NoSuchArticleException, SystemException {
15671                    JournalArticle journalArticle = findByPrimaryKey(id);
15672    
15673                    Session session = null;
15674    
15675                    try {
15676                            session = openSession();
15677    
15678                            JournalArticle[] array = new JournalArticleImpl[3];
15679    
15680                            array[0] = getByC_V_PrevAndNext(session, journalArticle, companyId,
15681                                            version, orderByComparator, true);
15682    
15683                            array[1] = journalArticle;
15684    
15685                            array[2] = getByC_V_PrevAndNext(session, journalArticle, companyId,
15686                                            version, orderByComparator, false);
15687    
15688                            return array;
15689                    }
15690                    catch (Exception e) {
15691                            throw processException(e);
15692                    }
15693                    finally {
15694                            closeSession(session);
15695                    }
15696            }
15697    
15698            protected JournalArticle getByC_V_PrevAndNext(Session session,
15699                    JournalArticle journalArticle, long companyId, double version,
15700                    OrderByComparator orderByComparator, boolean previous) {
15701                    StringBundler query = null;
15702    
15703                    if (orderByComparator != null) {
15704                            query = new StringBundler(6 +
15705                                            (orderByComparator.getOrderByFields().length * 6));
15706                    }
15707                    else {
15708                            query = new StringBundler(3);
15709                    }
15710    
15711                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15712    
15713                    query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
15714    
15715                    query.append(_FINDER_COLUMN_C_V_VERSION_2);
15716    
15717                    if (orderByComparator != null) {
15718                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15719    
15720                            if (orderByConditionFields.length > 0) {
15721                                    query.append(WHERE_AND);
15722                            }
15723    
15724                            for (int i = 0; i < orderByConditionFields.length; i++) {
15725                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15726                                    query.append(orderByConditionFields[i]);
15727    
15728                                    if ((i + 1) < orderByConditionFields.length) {
15729                                            if (orderByComparator.isAscending() ^ previous) {
15730                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15731                                            }
15732                                            else {
15733                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15734                                            }
15735                                    }
15736                                    else {
15737                                            if (orderByComparator.isAscending() ^ previous) {
15738                                                    query.append(WHERE_GREATER_THAN);
15739                                            }
15740                                            else {
15741                                                    query.append(WHERE_LESSER_THAN);
15742                                            }
15743                                    }
15744                            }
15745    
15746                            query.append(ORDER_BY_CLAUSE);
15747    
15748                            String[] orderByFields = orderByComparator.getOrderByFields();
15749    
15750                            for (int i = 0; i < orderByFields.length; i++) {
15751                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15752                                    query.append(orderByFields[i]);
15753    
15754                                    if ((i + 1) < orderByFields.length) {
15755                                            if (orderByComparator.isAscending() ^ previous) {
15756                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15757                                            }
15758                                            else {
15759                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15760                                            }
15761                                    }
15762                                    else {
15763                                            if (orderByComparator.isAscending() ^ previous) {
15764                                                    query.append(ORDER_BY_ASC);
15765                                            }
15766                                            else {
15767                                                    query.append(ORDER_BY_DESC);
15768                                            }
15769                                    }
15770                            }
15771                    }
15772                    else {
15773                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15774                    }
15775    
15776                    String sql = query.toString();
15777    
15778                    Query q = session.createQuery(sql);
15779    
15780                    q.setFirstResult(0);
15781                    q.setMaxResults(2);
15782    
15783                    QueryPos qPos = QueryPos.getInstance(q);
15784    
15785                    qPos.add(companyId);
15786    
15787                    qPos.add(version);
15788    
15789                    if (orderByComparator != null) {
15790                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
15791    
15792                            for (Object value : values) {
15793                                    qPos.add(value);
15794                            }
15795                    }
15796    
15797                    List<JournalArticle> list = q.list();
15798    
15799                    if (list.size() == 2) {
15800                            return list.get(1);
15801                    }
15802                    else {
15803                            return null;
15804                    }
15805            }
15806    
15807            /**
15808             * Removes all the journal articles where companyId = &#63; and version = &#63; from the database.
15809             *
15810             * @param companyId the company ID
15811             * @param version the version
15812             * @throws SystemException if a system exception occurred
15813             */
15814            @Override
15815            public void removeByC_V(long companyId, double version)
15816                    throws SystemException {
15817                    for (JournalArticle journalArticle : findByC_V(companyId, version,
15818                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15819                            remove(journalArticle);
15820                    }
15821            }
15822    
15823            /**
15824             * Returns the number of journal articles where companyId = &#63; and version = &#63;.
15825             *
15826             * @param companyId the company ID
15827             * @param version the version
15828             * @return the number of matching journal articles
15829             * @throws SystemException if a system exception occurred
15830             */
15831            @Override
15832            public int countByC_V(long companyId, double version)
15833                    throws SystemException {
15834                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_V;
15835    
15836                    Object[] finderArgs = new Object[] { companyId, version };
15837    
15838                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
15839                                    this);
15840    
15841                    if (count == null) {
15842                            StringBundler query = new StringBundler(3);
15843    
15844                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15845    
15846                            query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
15847    
15848                            query.append(_FINDER_COLUMN_C_V_VERSION_2);
15849    
15850                            String sql = query.toString();
15851    
15852                            Session session = null;
15853    
15854                            try {
15855                                    session = openSession();
15856    
15857                                    Query q = session.createQuery(sql);
15858    
15859                                    QueryPos qPos = QueryPos.getInstance(q);
15860    
15861                                    qPos.add(companyId);
15862    
15863                                    qPos.add(version);
15864    
15865                                    count = (Long)q.uniqueResult();
15866    
15867                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
15868                            }
15869                            catch (Exception e) {
15870                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15871    
15872                                    throw processException(e);
15873                            }
15874                            finally {
15875                                    closeSession(session);
15876                            }
15877                    }
15878    
15879                    return count.intValue();
15880            }
15881    
15882            private static final String _FINDER_COLUMN_C_V_COMPANYID_2 = "journalArticle.companyId = ? AND ";
15883            private static final String _FINDER_COLUMN_C_V_VERSION_2 = "journalArticle.version = ?";
15884            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15885                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
15886                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
15887                            "findByC_ST",
15888                            new String[] {
15889                                    Long.class.getName(), Integer.class.getName(),
15890                                    
15891                            Integer.class.getName(), Integer.class.getName(),
15892                                    OrderByComparator.class.getName()
15893                            });
15894            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15895                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
15896                            JournalArticleImpl.class,
15897                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_ST",
15898                            new String[] { Long.class.getName(), Integer.class.getName() },
15899                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
15900                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
15901                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
15902                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
15903            public static final FinderPath FINDER_PATH_COUNT_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15904                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
15905                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_ST",
15906                            new String[] { Long.class.getName(), Integer.class.getName() });
15907    
15908            /**
15909             * Returns all the journal articles where companyId = &#63; and status = &#63;.
15910             *
15911             * @param companyId the company ID
15912             * @param status the status
15913             * @return the matching journal articles
15914             * @throws SystemException if a system exception occurred
15915             */
15916            @Override
15917            public List<JournalArticle> findByC_ST(long companyId, int status)
15918                    throws SystemException {
15919                    return findByC_ST(companyId, status, QueryUtil.ALL_POS,
15920                            QueryUtil.ALL_POS, null);
15921            }
15922    
15923            /**
15924             * Returns a range of all the journal articles where companyId = &#63; and status = &#63;.
15925             *
15926             * <p>
15927             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15928             * </p>
15929             *
15930             * @param companyId the company ID
15931             * @param status the status
15932             * @param start the lower bound of the range of journal articles
15933             * @param end the upper bound of the range of journal articles (not inclusive)
15934             * @return the range of matching journal articles
15935             * @throws SystemException if a system exception occurred
15936             */
15937            @Override
15938            public List<JournalArticle> findByC_ST(long companyId, int status,
15939                    int start, int end) throws SystemException {
15940                    return findByC_ST(companyId, status, start, end, null);
15941            }
15942    
15943            /**
15944             * Returns an ordered range of all the journal articles where companyId = &#63; and status = &#63;.
15945             *
15946             * <p>
15947             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15948             * </p>
15949             *
15950             * @param companyId the company ID
15951             * @param status the status
15952             * @param start the lower bound of the range of journal articles
15953             * @param end the upper bound of the range of journal articles (not inclusive)
15954             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15955             * @return the ordered range of matching journal articles
15956             * @throws SystemException if a system exception occurred
15957             */
15958            @Override
15959            public List<JournalArticle> findByC_ST(long companyId, int status,
15960                    int start, int end, OrderByComparator orderByComparator)
15961                    throws SystemException {
15962                    boolean pagination = true;
15963                    FinderPath finderPath = null;
15964                    Object[] finderArgs = null;
15965    
15966                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
15967                                    (orderByComparator == null)) {
15968                            pagination = false;
15969                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST;
15970                            finderArgs = new Object[] { companyId, status };
15971                    }
15972                    else {
15973                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_ST;
15974                            finderArgs = new Object[] {
15975                                            companyId, status,
15976                                            
15977                                            start, end, orderByComparator
15978                                    };
15979                    }
15980    
15981                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
15982                                    finderArgs, this);
15983    
15984                    if ((list != null) && !list.isEmpty()) {
15985                            for (JournalArticle journalArticle : list) {
15986                                    if ((companyId != journalArticle.getCompanyId()) ||
15987                                                    (status != journalArticle.getStatus())) {
15988                                            list = null;
15989    
15990                                            break;
15991                                    }
15992                            }
15993                    }
15994    
15995                    if (list == null) {
15996                            StringBundler query = null;
15997    
15998                            if (orderByComparator != null) {
15999                                    query = new StringBundler(4 +
16000                                                    (orderByComparator.getOrderByFields().length * 3));
16001                            }
16002                            else {
16003                                    query = new StringBundler(4);
16004                            }
16005    
16006                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16007    
16008                            query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
16009    
16010                            query.append(_FINDER_COLUMN_C_ST_STATUS_2);
16011    
16012                            if (orderByComparator != null) {
16013                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16014                                            orderByComparator);
16015                            }
16016                            else
16017                             if (pagination) {
16018                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16019                            }
16020    
16021                            String sql = query.toString();
16022    
16023                            Session session = null;
16024    
16025                            try {
16026                                    session = openSession();
16027    
16028                                    Query q = session.createQuery(sql);
16029    
16030                                    QueryPos qPos = QueryPos.getInstance(q);
16031    
16032                                    qPos.add(companyId);
16033    
16034                                    qPos.add(status);
16035    
16036                                    if (!pagination) {
16037                                            list = (List<JournalArticle>)QueryUtil.list(q,
16038                                                            getDialect(), start, end, false);
16039    
16040                                            Collections.sort(list);
16041    
16042                                            list = new UnmodifiableList<JournalArticle>(list);
16043                                    }
16044                                    else {
16045                                            list = (List<JournalArticle>)QueryUtil.list(q,
16046                                                            getDialect(), start, end);
16047                                    }
16048    
16049                                    cacheResult(list);
16050    
16051                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
16052                            }
16053                            catch (Exception e) {
16054                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16055    
16056                                    throw processException(e);
16057                            }
16058                            finally {
16059                                    closeSession(session);
16060                            }
16061                    }
16062    
16063                    return list;
16064            }
16065    
16066            /**
16067             * Returns the first journal article in the ordered set where companyId = &#63; and status = &#63;.
16068             *
16069             * @param companyId the company ID
16070             * @param status the status
16071             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16072             * @return the first matching journal article
16073             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
16074             * @throws SystemException if a system exception occurred
16075             */
16076            @Override
16077            public JournalArticle findByC_ST_First(long companyId, int status,
16078                    OrderByComparator orderByComparator)
16079                    throws NoSuchArticleException, SystemException {
16080                    JournalArticle journalArticle = fetchByC_ST_First(companyId, status,
16081                                    orderByComparator);
16082    
16083                    if (journalArticle != null) {
16084                            return journalArticle;
16085                    }
16086    
16087                    StringBundler msg = new StringBundler(6);
16088    
16089                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16090    
16091                    msg.append("companyId=");
16092                    msg.append(companyId);
16093    
16094                    msg.append(", status=");
16095                    msg.append(status);
16096    
16097                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16098    
16099                    throw new NoSuchArticleException(msg.toString());
16100            }
16101    
16102            /**
16103             * Returns the first journal article in the ordered set where companyId = &#63; and status = &#63;.
16104             *
16105             * @param companyId the company ID
16106             * @param status the status
16107             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16108             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
16109             * @throws SystemException if a system exception occurred
16110             */
16111            @Override
16112            public JournalArticle fetchByC_ST_First(long companyId, int status,
16113                    OrderByComparator orderByComparator) throws SystemException {
16114                    List<JournalArticle> list = findByC_ST(companyId, status, 0, 1,
16115                                    orderByComparator);
16116    
16117                    if (!list.isEmpty()) {
16118                            return list.get(0);
16119                    }
16120    
16121                    return null;
16122            }
16123    
16124            /**
16125             * Returns the last journal article in the ordered set where companyId = &#63; and status = &#63;.
16126             *
16127             * @param companyId the company ID
16128             * @param status the status
16129             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16130             * @return the last matching journal article
16131             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
16132             * @throws SystemException if a system exception occurred
16133             */
16134            @Override
16135            public JournalArticle findByC_ST_Last(long companyId, int status,
16136                    OrderByComparator orderByComparator)
16137                    throws NoSuchArticleException, SystemException {
16138                    JournalArticle journalArticle = fetchByC_ST_Last(companyId, status,
16139                                    orderByComparator);
16140    
16141                    if (journalArticle != null) {
16142                            return journalArticle;
16143                    }
16144    
16145                    StringBundler msg = new StringBundler(6);
16146    
16147                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16148    
16149                    msg.append("companyId=");
16150                    msg.append(companyId);
16151    
16152                    msg.append(", status=");
16153                    msg.append(status);
16154    
16155                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16156    
16157                    throw new NoSuchArticleException(msg.toString());
16158            }
16159    
16160            /**
16161             * Returns the last journal article in the ordered set where companyId = &#63; and status = &#63;.
16162             *
16163             * @param companyId the company ID
16164             * @param status the status
16165             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16166             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
16167             * @throws SystemException if a system exception occurred
16168             */
16169            @Override
16170            public JournalArticle fetchByC_ST_Last(long companyId, int status,
16171                    OrderByComparator orderByComparator) throws SystemException {
16172                    int count = countByC_ST(companyId, status);
16173    
16174                    if (count == 0) {
16175                            return null;
16176                    }
16177    
16178                    List<JournalArticle> list = findByC_ST(companyId, status, count - 1,
16179                                    count, orderByComparator);
16180    
16181                    if (!list.isEmpty()) {
16182                            return list.get(0);
16183                    }
16184    
16185                    return null;
16186            }
16187    
16188            /**
16189             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and status = &#63;.
16190             *
16191             * @param id the primary key of the current journal article
16192             * @param companyId the company ID
16193             * @param status the status
16194             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16195             * @return the previous, current, and next journal article
16196             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
16197             * @throws SystemException if a system exception occurred
16198             */
16199            @Override
16200            public JournalArticle[] findByC_ST_PrevAndNext(long id, long companyId,
16201                    int status, OrderByComparator orderByComparator)
16202                    throws NoSuchArticleException, SystemException {
16203                    JournalArticle journalArticle = findByPrimaryKey(id);
16204    
16205                    Session session = null;
16206    
16207                    try {
16208                            session = openSession();
16209    
16210                            JournalArticle[] array = new JournalArticleImpl[3];
16211    
16212                            array[0] = getByC_ST_PrevAndNext(session, journalArticle,
16213                                            companyId, status, orderByComparator, true);
16214    
16215                            array[1] = journalArticle;
16216    
16217                            array[2] = getByC_ST_PrevAndNext(session, journalArticle,
16218                                            companyId, status, orderByComparator, false);
16219    
16220                            return array;
16221                    }
16222                    catch (Exception e) {
16223                            throw processException(e);
16224                    }
16225                    finally {
16226                            closeSession(session);
16227                    }
16228            }
16229    
16230            protected JournalArticle getByC_ST_PrevAndNext(Session session,
16231                    JournalArticle journalArticle, long companyId, int status,
16232                    OrderByComparator orderByComparator, boolean previous) {
16233                    StringBundler query = null;
16234    
16235                    if (orderByComparator != null) {
16236                            query = new StringBundler(6 +
16237                                            (orderByComparator.getOrderByFields().length * 6));
16238                    }
16239                    else {
16240                            query = new StringBundler(3);
16241                    }
16242    
16243                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16244    
16245                    query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
16246    
16247                    query.append(_FINDER_COLUMN_C_ST_STATUS_2);
16248    
16249                    if (orderByComparator != null) {
16250                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16251    
16252                            if (orderByConditionFields.length > 0) {
16253                                    query.append(WHERE_AND);
16254                            }
16255    
16256                            for (int i = 0; i < orderByConditionFields.length; i++) {
16257                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16258                                    query.append(orderByConditionFields[i]);
16259    
16260                                    if ((i + 1) < orderByConditionFields.length) {
16261                                            if (orderByComparator.isAscending() ^ previous) {
16262                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16263                                            }
16264                                            else {
16265                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16266                                            }
16267                                    }
16268                                    else {
16269                                            if (orderByComparator.isAscending() ^ previous) {
16270                                                    query.append(WHERE_GREATER_THAN);
16271                                            }
16272                                            else {
16273                                                    query.append(WHERE_LESSER_THAN);
16274                                            }
16275                                    }
16276                            }
16277    
16278                            query.append(ORDER_BY_CLAUSE);
16279    
16280                            String[] orderByFields = orderByComparator.getOrderByFields();
16281    
16282                            for (int i = 0; i < orderByFields.length; i++) {
16283                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16284                                    query.append(orderByFields[i]);
16285    
16286                                    if ((i + 1) < orderByFields.length) {
16287                                            if (orderByComparator.isAscending() ^ previous) {
16288                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16289                                            }
16290                                            else {
16291                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16292                                            }
16293                                    }
16294                                    else {
16295                                            if (orderByComparator.isAscending() ^ previous) {
16296                                                    query.append(ORDER_BY_ASC);
16297                                            }
16298                                            else {
16299                                                    query.append(ORDER_BY_DESC);
16300                                            }
16301                                    }
16302                            }
16303                    }
16304                    else {
16305                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16306                    }
16307    
16308                    String sql = query.toString();
16309    
16310                    Query q = session.createQuery(sql);
16311    
16312                    q.setFirstResult(0);
16313                    q.setMaxResults(2);
16314    
16315                    QueryPos qPos = QueryPos.getInstance(q);
16316    
16317                    qPos.add(companyId);
16318    
16319                    qPos.add(status);
16320    
16321                    if (orderByComparator != null) {
16322                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
16323    
16324                            for (Object value : values) {
16325                                    qPos.add(value);
16326                            }
16327                    }
16328    
16329                    List<JournalArticle> list = q.list();
16330    
16331                    if (list.size() == 2) {
16332                            return list.get(1);
16333                    }
16334                    else {
16335                            return null;
16336                    }
16337            }
16338    
16339            /**
16340             * Removes all the journal articles where companyId = &#63; and status = &#63; from the database.
16341             *
16342             * @param companyId the company ID
16343             * @param status the status
16344             * @throws SystemException if a system exception occurred
16345             */
16346            @Override
16347            public void removeByC_ST(long companyId, int status)
16348                    throws SystemException {
16349                    for (JournalArticle journalArticle : findByC_ST(companyId, status,
16350                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
16351                            remove(journalArticle);
16352                    }
16353            }
16354    
16355            /**
16356             * Returns the number of journal articles where companyId = &#63; and status = &#63;.
16357             *
16358             * @param companyId the company ID
16359             * @param status the status
16360             * @return the number of matching journal articles
16361             * @throws SystemException if a system exception occurred
16362             */
16363            @Override
16364            public int countByC_ST(long companyId, int status)
16365                    throws SystemException {
16366                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_ST;
16367    
16368                    Object[] finderArgs = new Object[] { companyId, status };
16369    
16370                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
16371                                    this);
16372    
16373                    if (count == null) {
16374                            StringBundler query = new StringBundler(3);
16375    
16376                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16377    
16378                            query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
16379    
16380                            query.append(_FINDER_COLUMN_C_ST_STATUS_2);
16381    
16382                            String sql = query.toString();
16383    
16384                            Session session = null;
16385    
16386                            try {
16387                                    session = openSession();
16388    
16389                                    Query q = session.createQuery(sql);
16390    
16391                                    QueryPos qPos = QueryPos.getInstance(q);
16392    
16393                                    qPos.add(companyId);
16394    
16395                                    qPos.add(status);
16396    
16397                                    count = (Long)q.uniqueResult();
16398    
16399                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
16400                            }
16401                            catch (Exception e) {
16402                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16403    
16404                                    throw processException(e);
16405                            }
16406                            finally {
16407                                    closeSession(session);
16408                            }
16409                    }
16410    
16411                    return count.intValue();
16412            }
16413    
16414            private static final String _FINDER_COLUMN_C_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
16415            private static final String _FINDER_COLUMN_C_ST_STATUS_2 = "journalArticle.status = ?";
16416            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16417                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
16418                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
16419                            "findByC_NotST",
16420                            new String[] {
16421                                    Long.class.getName(), Integer.class.getName(),
16422                                    
16423                            Integer.class.getName(), Integer.class.getName(),
16424                                    OrderByComparator.class.getName()
16425                            });
16426            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16427                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
16428                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_NotST",
16429                            new String[] { Long.class.getName(), Integer.class.getName() });
16430    
16431            /**
16432             * Returns all the journal articles where companyId = &#63; and status &ne; &#63;.
16433             *
16434             * @param companyId the company ID
16435             * @param status the status
16436             * @return the matching journal articles
16437             * @throws SystemException if a system exception occurred
16438             */
16439            @Override
16440            public List<JournalArticle> findByC_NotST(long companyId, int status)
16441                    throws SystemException {
16442                    return findByC_NotST(companyId, status, QueryUtil.ALL_POS,
16443                            QueryUtil.ALL_POS, null);
16444            }
16445    
16446            /**
16447             * Returns a range of all the journal articles where companyId = &#63; and status &ne; &#63;.
16448             *
16449             * <p>
16450             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16451             * </p>
16452             *
16453             * @param companyId the company ID
16454             * @param status the status
16455             * @param start the lower bound of the range of journal articles
16456             * @param end the upper bound of the range of journal articles (not inclusive)
16457             * @return the range of matching journal articles
16458             * @throws SystemException if a system exception occurred
16459             */
16460            @Override
16461            public List<JournalArticle> findByC_NotST(long companyId, int status,
16462                    int start, int end) throws SystemException {
16463                    return findByC_NotST(companyId, status, start, end, null);
16464            }
16465    
16466            /**
16467             * Returns an ordered range of all the journal articles where companyId = &#63; and status &ne; &#63;.
16468             *
16469             * <p>
16470             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16471             * </p>
16472             *
16473             * @param companyId the company ID
16474             * @param status the status
16475             * @param start the lower bound of the range of journal articles
16476             * @param end the upper bound of the range of journal articles (not inclusive)
16477             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16478             * @return the ordered range of matching journal articles
16479             * @throws SystemException if a system exception occurred
16480             */
16481            @Override
16482            public List<JournalArticle> findByC_NotST(long companyId, int status,
16483                    int start, int end, OrderByComparator orderByComparator)
16484                    throws SystemException {
16485                    boolean pagination = true;
16486                    FinderPath finderPath = null;
16487                    Object[] finderArgs = null;
16488    
16489                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTST;
16490                    finderArgs = new Object[] {
16491                                    companyId, status,
16492                                    
16493                                    start, end, orderByComparator
16494                            };
16495    
16496                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
16497                                    finderArgs, this);
16498    
16499                    if ((list != null) && !list.isEmpty()) {
16500                            for (JournalArticle journalArticle : list) {
16501                                    if ((companyId != journalArticle.getCompanyId()) ||
16502                                                    (status == journalArticle.getStatus())) {
16503                                            list = null;
16504    
16505                                            break;
16506                                    }
16507                            }
16508                    }
16509    
16510                    if (list == null) {
16511                            StringBundler query = null;
16512    
16513                            if (orderByComparator != null) {
16514                                    query = new StringBundler(4 +
16515                                                    (orderByComparator.getOrderByFields().length * 3));
16516                            }
16517                            else {
16518                                    query = new StringBundler(4);
16519                            }
16520    
16521                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16522    
16523                            query.append(_FINDER_COLUMN_C_NOTST_COMPANYID_2);
16524    
16525                            query.append(_FINDER_COLUMN_C_NOTST_STATUS_2);
16526    
16527                            if (orderByComparator != null) {
16528                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16529                                            orderByComparator);
16530                            }
16531                            else
16532                             if (pagination) {
16533                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16534                            }
16535    
16536                            String sql = query.toString();
16537    
16538                            Session session = null;
16539    
16540                            try {
16541                                    session = openSession();
16542    
16543                                    Query q = session.createQuery(sql);
16544    
16545                                    QueryPos qPos = QueryPos.getInstance(q);
16546    
16547                                    qPos.add(companyId);
16548    
16549                                    qPos.add(status);
16550    
16551                                    if (!pagination) {
16552                                            list = (List<JournalArticle>)QueryUtil.list(q,
16553                                                            getDialect(), start, end, false);
16554    
16555                                            Collections.sort(list);
16556    
16557                                            list = new UnmodifiableList<JournalArticle>(list);
16558                                    }
16559                                    else {
16560                                            list = (List<JournalArticle>)QueryUtil.list(q,
16561                                                            getDialect(), start, end);
16562                                    }
16563    
16564                                    cacheResult(list);
16565    
16566                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
16567                            }
16568                            catch (Exception e) {
16569                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16570    
16571                                    throw processException(e);
16572                            }
16573                            finally {
16574                                    closeSession(session);
16575                            }
16576                    }
16577    
16578                    return list;
16579            }
16580    
16581            /**
16582             * Returns the first journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
16583             *
16584             * @param companyId the company ID
16585             * @param status the status
16586             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16587             * @return the first matching journal article
16588             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
16589             * @throws SystemException if a system exception occurred
16590             */
16591            @Override
16592            public JournalArticle findByC_NotST_First(long companyId, int status,
16593                    OrderByComparator orderByComparator)
16594                    throws NoSuchArticleException, SystemException {
16595                    JournalArticle journalArticle = fetchByC_NotST_First(companyId, status,
16596                                    orderByComparator);
16597    
16598                    if (journalArticle != null) {
16599                            return journalArticle;
16600                    }
16601    
16602                    StringBundler msg = new StringBundler(6);
16603    
16604                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16605    
16606                    msg.append("companyId=");
16607                    msg.append(companyId);
16608    
16609                    msg.append(", status=");
16610                    msg.append(status);
16611    
16612                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16613    
16614                    throw new NoSuchArticleException(msg.toString());
16615            }
16616    
16617            /**
16618             * Returns the first journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
16619             *
16620             * @param companyId the company ID
16621             * @param status the status
16622             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16623             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
16624             * @throws SystemException if a system exception occurred
16625             */
16626            @Override
16627            public JournalArticle fetchByC_NotST_First(long companyId, int status,
16628                    OrderByComparator orderByComparator) throws SystemException {
16629                    List<JournalArticle> list = findByC_NotST(companyId, status, 0, 1,
16630                                    orderByComparator);
16631    
16632                    if (!list.isEmpty()) {
16633                            return list.get(0);
16634                    }
16635    
16636                    return null;
16637            }
16638    
16639            /**
16640             * Returns the last journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
16641             *
16642             * @param companyId the company ID
16643             * @param status the status
16644             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16645             * @return the last matching journal article
16646             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
16647             * @throws SystemException if a system exception occurred
16648             */
16649            @Override
16650            public JournalArticle findByC_NotST_Last(long companyId, int status,
16651                    OrderByComparator orderByComparator)
16652                    throws NoSuchArticleException, SystemException {
16653                    JournalArticle journalArticle = fetchByC_NotST_Last(companyId, status,
16654                                    orderByComparator);
16655    
16656                    if (journalArticle != null) {
16657                            return journalArticle;
16658                    }
16659    
16660                    StringBundler msg = new StringBundler(6);
16661    
16662                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16663    
16664                    msg.append("companyId=");
16665                    msg.append(companyId);
16666    
16667                    msg.append(", status=");
16668                    msg.append(status);
16669    
16670                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16671    
16672                    throw new NoSuchArticleException(msg.toString());
16673            }
16674    
16675            /**
16676             * Returns the last journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
16677             *
16678             * @param companyId the company ID
16679             * @param status the status
16680             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16681             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
16682             * @throws SystemException if a system exception occurred
16683             */
16684            @Override
16685            public JournalArticle fetchByC_NotST_Last(long companyId, int status,
16686                    OrderByComparator orderByComparator) throws SystemException {
16687                    int count = countByC_NotST(companyId, status);
16688    
16689                    if (count == 0) {
16690                            return null;
16691                    }
16692    
16693                    List<JournalArticle> list = findByC_NotST(companyId, status, count - 1,
16694                                    count, orderByComparator);
16695    
16696                    if (!list.isEmpty()) {
16697                            return list.get(0);
16698                    }
16699    
16700                    return null;
16701            }
16702    
16703            /**
16704             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
16705             *
16706             * @param id the primary key of the current journal article
16707             * @param companyId the company ID
16708             * @param status the status
16709             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16710             * @return the previous, current, and next journal article
16711             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
16712             * @throws SystemException if a system exception occurred
16713             */
16714            @Override
16715            public JournalArticle[] findByC_NotST_PrevAndNext(long id, long companyId,
16716                    int status, OrderByComparator orderByComparator)
16717                    throws NoSuchArticleException, SystemException {
16718                    JournalArticle journalArticle = findByPrimaryKey(id);
16719    
16720                    Session session = null;
16721    
16722                    try {
16723                            session = openSession();
16724    
16725                            JournalArticle[] array = new JournalArticleImpl[3];
16726    
16727                            array[0] = getByC_NotST_PrevAndNext(session, journalArticle,
16728                                            companyId, status, orderByComparator, true);
16729    
16730                            array[1] = journalArticle;
16731    
16732                            array[2] = getByC_NotST_PrevAndNext(session, journalArticle,
16733                                            companyId, status, orderByComparator, false);
16734    
16735                            return array;
16736                    }
16737                    catch (Exception e) {
16738                            throw processException(e);
16739                    }
16740                    finally {
16741                            closeSession(session);
16742                    }
16743            }
16744    
16745            protected JournalArticle getByC_NotST_PrevAndNext(Session session,
16746                    JournalArticle journalArticle, long companyId, int status,
16747                    OrderByComparator orderByComparator, boolean previous) {
16748                    StringBundler query = null;
16749    
16750                    if (orderByComparator != null) {
16751                            query = new StringBundler(6 +
16752                                            (orderByComparator.getOrderByFields().length * 6));
16753                    }
16754                    else {
16755                            query = new StringBundler(3);
16756                    }
16757    
16758                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16759    
16760                    query.append(_FINDER_COLUMN_C_NOTST_COMPANYID_2);
16761    
16762                    query.append(_FINDER_COLUMN_C_NOTST_STATUS_2);
16763    
16764                    if (orderByComparator != null) {
16765                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16766    
16767                            if (orderByConditionFields.length > 0) {
16768                                    query.append(WHERE_AND);
16769                            }
16770    
16771                            for (int i = 0; i < orderByConditionFields.length; i++) {
16772                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16773                                    query.append(orderByConditionFields[i]);
16774    
16775                                    if ((i + 1) < orderByConditionFields.length) {
16776                                            if (orderByComparator.isAscending() ^ previous) {
16777                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16778                                            }
16779                                            else {
16780                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16781                                            }
16782                                    }
16783                                    else {
16784                                            if (orderByComparator.isAscending() ^ previous) {
16785                                                    query.append(WHERE_GREATER_THAN);
16786                                            }
16787                                            else {
16788                                                    query.append(WHERE_LESSER_THAN);
16789                                            }
16790                                    }
16791                            }
16792    
16793                            query.append(ORDER_BY_CLAUSE);
16794    
16795                            String[] orderByFields = orderByComparator.getOrderByFields();
16796    
16797                            for (int i = 0; i < orderByFields.length; i++) {
16798                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16799                                    query.append(orderByFields[i]);
16800    
16801                                    if ((i + 1) < orderByFields.length) {
16802                                            if (orderByComparator.isAscending() ^ previous) {
16803                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16804                                            }
16805                                            else {
16806                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16807                                            }
16808                                    }
16809                                    else {
16810                                            if (orderByComparator.isAscending() ^ previous) {
16811                                                    query.append(ORDER_BY_ASC);
16812                                            }
16813                                            else {
16814                                                    query.append(ORDER_BY_DESC);
16815                                            }
16816                                    }
16817                            }
16818                    }
16819                    else {
16820                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16821                    }
16822    
16823                    String sql = query.toString();
16824    
16825                    Query q = session.createQuery(sql);
16826    
16827                    q.setFirstResult(0);
16828                    q.setMaxResults(2);
16829    
16830                    QueryPos qPos = QueryPos.getInstance(q);
16831    
16832                    qPos.add(companyId);
16833    
16834                    qPos.add(status);
16835    
16836                    if (orderByComparator != null) {
16837                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
16838    
16839                            for (Object value : values) {
16840                                    qPos.add(value);
16841                            }
16842                    }
16843    
16844                    List<JournalArticle> list = q.list();
16845    
16846                    if (list.size() == 2) {
16847                            return list.get(1);
16848                    }
16849                    else {
16850                            return null;
16851                    }
16852            }
16853    
16854            /**
16855             * Removes all the journal articles where companyId = &#63; and status &ne; &#63; from the database.
16856             *
16857             * @param companyId the company ID
16858             * @param status the status
16859             * @throws SystemException if a system exception occurred
16860             */
16861            @Override
16862            public void removeByC_NotST(long companyId, int status)
16863                    throws SystemException {
16864                    for (JournalArticle journalArticle : findByC_NotST(companyId, status,
16865                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
16866                            remove(journalArticle);
16867                    }
16868            }
16869    
16870            /**
16871             * Returns the number of journal articles where companyId = &#63; and status &ne; &#63;.
16872             *
16873             * @param companyId the company ID
16874             * @param status the status
16875             * @return the number of matching journal articles
16876             * @throws SystemException if a system exception occurred
16877             */
16878            @Override
16879            public int countByC_NotST(long companyId, int status)
16880                    throws SystemException {
16881                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTST;
16882    
16883                    Object[] finderArgs = new Object[] { companyId, status };
16884    
16885                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
16886                                    this);
16887    
16888                    if (count == null) {
16889                            StringBundler query = new StringBundler(3);
16890    
16891                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16892    
16893                            query.append(_FINDER_COLUMN_C_NOTST_COMPANYID_2);
16894    
16895                            query.append(_FINDER_COLUMN_C_NOTST_STATUS_2);
16896    
16897                            String sql = query.toString();
16898    
16899                            Session session = null;
16900    
16901                            try {
16902                                    session = openSession();
16903    
16904                                    Query q = session.createQuery(sql);
16905    
16906                                    QueryPos qPos = QueryPos.getInstance(q);
16907    
16908                                    qPos.add(companyId);
16909    
16910                                    qPos.add(status);
16911    
16912                                    count = (Long)q.uniqueResult();
16913    
16914                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
16915                            }
16916                            catch (Exception e) {
16917                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16918    
16919                                    throw processException(e);
16920                            }
16921                            finally {
16922                                    closeSession(session);
16923                            }
16924                    }
16925    
16926                    return count.intValue();
16927            }
16928    
16929            private static final String _FINDER_COLUMN_C_NOTST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
16930            private static final String _FINDER_COLUMN_C_NOTST_STATUS_2 = "journalArticle.status != ?";
16931            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16932                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
16933                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
16934                            "findByC_T",
16935                            new String[] {
16936                                    Long.class.getName(), String.class.getName(),
16937                                    
16938                            Integer.class.getName(), Integer.class.getName(),
16939                                    OrderByComparator.class.getName()
16940                            });
16941            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16942                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
16943                            JournalArticleImpl.class,
16944                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_T",
16945                            new String[] { Long.class.getName(), String.class.getName() },
16946                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
16947                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK |
16948                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
16949                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
16950            public static final FinderPath FINDER_PATH_COUNT_BY_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16951                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
16952                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_T",
16953                            new String[] { Long.class.getName(), String.class.getName() });
16954    
16955            /**
16956             * Returns all the journal articles where classNameId = &#63; and templateId = &#63;.
16957             *
16958             * @param classNameId the class name ID
16959             * @param templateId the template ID
16960             * @return the matching journal articles
16961             * @throws SystemException if a system exception occurred
16962             */
16963            @Override
16964            public List<JournalArticle> findByC_T(long classNameId, String templateId)
16965                    throws SystemException {
16966                    return findByC_T(classNameId, templateId, QueryUtil.ALL_POS,
16967                            QueryUtil.ALL_POS, null);
16968            }
16969    
16970            /**
16971             * Returns a range of all the journal articles where classNameId = &#63; and templateId = &#63;.
16972             *
16973             * <p>
16974             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16975             * </p>
16976             *
16977             * @param classNameId the class name ID
16978             * @param templateId the template ID
16979             * @param start the lower bound of the range of journal articles
16980             * @param end the upper bound of the range of journal articles (not inclusive)
16981             * @return the range of matching journal articles
16982             * @throws SystemException if a system exception occurred
16983             */
16984            @Override
16985            public List<JournalArticle> findByC_T(long classNameId, String templateId,
16986                    int start, int end) throws SystemException {
16987                    return findByC_T(classNameId, templateId, start, end, null);
16988            }
16989    
16990            /**
16991             * Returns an ordered range of all the journal articles where classNameId = &#63; and templateId = &#63;.
16992             *
16993             * <p>
16994             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16995             * </p>
16996             *
16997             * @param classNameId the class name ID
16998             * @param templateId the template ID
16999             * @param start the lower bound of the range of journal articles
17000             * @param end the upper bound of the range of journal articles (not inclusive)
17001             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17002             * @return the ordered range of matching journal articles
17003             * @throws SystemException if a system exception occurred
17004             */
17005            @Override
17006            public List<JournalArticle> findByC_T(long classNameId, String templateId,
17007                    int start, int end, OrderByComparator orderByComparator)
17008                    throws SystemException {
17009                    boolean pagination = true;
17010                    FinderPath finderPath = null;
17011                    Object[] finderArgs = null;
17012    
17013                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
17014                                    (orderByComparator == null)) {
17015                            pagination = false;
17016                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T;
17017                            finderArgs = new Object[] { classNameId, templateId };
17018                    }
17019                    else {
17020                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_T;
17021                            finderArgs = new Object[] {
17022                                            classNameId, templateId,
17023                                            
17024                                            start, end, orderByComparator
17025                                    };
17026                    }
17027    
17028                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
17029                                    finderArgs, this);
17030    
17031                    if ((list != null) && !list.isEmpty()) {
17032                            for (JournalArticle journalArticle : list) {
17033                                    if ((classNameId != journalArticle.getClassNameId()) ||
17034                                                    !Validator.equals(templateId,
17035                                                            journalArticle.getTemplateId())) {
17036                                            list = null;
17037    
17038                                            break;
17039                                    }
17040                            }
17041                    }
17042    
17043                    if (list == null) {
17044                            StringBundler query = null;
17045    
17046                            if (orderByComparator != null) {
17047                                    query = new StringBundler(4 +
17048                                                    (orderByComparator.getOrderByFields().length * 3));
17049                            }
17050                            else {
17051                                    query = new StringBundler(4);
17052                            }
17053    
17054                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17055    
17056                            query.append(_FINDER_COLUMN_C_T_CLASSNAMEID_2);
17057    
17058                            boolean bindTemplateId = false;
17059    
17060                            if (templateId == null) {
17061                                    query.append(_FINDER_COLUMN_C_T_TEMPLATEID_1);
17062                            }
17063                            else if (templateId.equals(StringPool.BLANK)) {
17064                                    query.append(_FINDER_COLUMN_C_T_TEMPLATEID_3);
17065                            }
17066                            else {
17067                                    bindTemplateId = true;
17068    
17069                                    query.append(_FINDER_COLUMN_C_T_TEMPLATEID_2);
17070                            }
17071    
17072                            if (orderByComparator != null) {
17073                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17074                                            orderByComparator);
17075                            }
17076                            else
17077                             if (pagination) {
17078                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17079                            }
17080    
17081                            String sql = query.toString();
17082    
17083                            Session session = null;
17084    
17085                            try {
17086                                    session = openSession();
17087    
17088                                    Query q = session.createQuery(sql);
17089    
17090                                    QueryPos qPos = QueryPos.getInstance(q);
17091    
17092                                    qPos.add(classNameId);
17093    
17094                                    if (bindTemplateId) {
17095                                            qPos.add(templateId);
17096                                    }
17097    
17098                                    if (!pagination) {
17099                                            list = (List<JournalArticle>)QueryUtil.list(q,
17100                                                            getDialect(), start, end, false);
17101    
17102                                            Collections.sort(list);
17103    
17104                                            list = new UnmodifiableList<JournalArticle>(list);
17105                                    }
17106                                    else {
17107                                            list = (List<JournalArticle>)QueryUtil.list(q,
17108                                                            getDialect(), start, end);
17109                                    }
17110    
17111                                    cacheResult(list);
17112    
17113                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
17114                            }
17115                            catch (Exception e) {
17116                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17117    
17118                                    throw processException(e);
17119                            }
17120                            finally {
17121                                    closeSession(session);
17122                            }
17123                    }
17124    
17125                    return list;
17126            }
17127    
17128            /**
17129             * Returns the first journal article in the ordered set where classNameId = &#63; and templateId = &#63;.
17130             *
17131             * @param classNameId the class name ID
17132             * @param templateId the template ID
17133             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17134             * @return the first matching journal article
17135             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
17136             * @throws SystemException if a system exception occurred
17137             */
17138            @Override
17139            public JournalArticle findByC_T_First(long classNameId, String templateId,
17140                    OrderByComparator orderByComparator)
17141                    throws NoSuchArticleException, SystemException {
17142                    JournalArticle journalArticle = fetchByC_T_First(classNameId,
17143                                    templateId, orderByComparator);
17144    
17145                    if (journalArticle != null) {
17146                            return journalArticle;
17147                    }
17148    
17149                    StringBundler msg = new StringBundler(6);
17150    
17151                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17152    
17153                    msg.append("classNameId=");
17154                    msg.append(classNameId);
17155    
17156                    msg.append(", templateId=");
17157                    msg.append(templateId);
17158    
17159                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17160    
17161                    throw new NoSuchArticleException(msg.toString());
17162            }
17163    
17164            /**
17165             * Returns the first journal article in the ordered set where classNameId = &#63; and templateId = &#63;.
17166             *
17167             * @param classNameId the class name ID
17168             * @param templateId the template ID
17169             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17170             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
17171             * @throws SystemException if a system exception occurred
17172             */
17173            @Override
17174            public JournalArticle fetchByC_T_First(long classNameId, String templateId,
17175                    OrderByComparator orderByComparator) throws SystemException {
17176                    List<JournalArticle> list = findByC_T(classNameId, templateId, 0, 1,
17177                                    orderByComparator);
17178    
17179                    if (!list.isEmpty()) {
17180                            return list.get(0);
17181                    }
17182    
17183                    return null;
17184            }
17185    
17186            /**
17187             * Returns the last journal article in the ordered set where classNameId = &#63; and templateId = &#63;.
17188             *
17189             * @param classNameId the class name ID
17190             * @param templateId the template ID
17191             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17192             * @return the last matching journal article
17193             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
17194             * @throws SystemException if a system exception occurred
17195             */
17196            @Override
17197            public JournalArticle findByC_T_Last(long classNameId, String templateId,
17198                    OrderByComparator orderByComparator)
17199                    throws NoSuchArticleException, SystemException {
17200                    JournalArticle journalArticle = fetchByC_T_Last(classNameId,
17201                                    templateId, orderByComparator);
17202    
17203                    if (journalArticle != null) {
17204                            return journalArticle;
17205                    }
17206    
17207                    StringBundler msg = new StringBundler(6);
17208    
17209                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17210    
17211                    msg.append("classNameId=");
17212                    msg.append(classNameId);
17213    
17214                    msg.append(", templateId=");
17215                    msg.append(templateId);
17216    
17217                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17218    
17219                    throw new NoSuchArticleException(msg.toString());
17220            }
17221    
17222            /**
17223             * Returns the last journal article in the ordered set where classNameId = &#63; and templateId = &#63;.
17224             *
17225             * @param classNameId the class name ID
17226             * @param templateId the template ID
17227             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17228             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
17229             * @throws SystemException if a system exception occurred
17230             */
17231            @Override
17232            public JournalArticle fetchByC_T_Last(long classNameId, String templateId,
17233                    OrderByComparator orderByComparator) throws SystemException {
17234                    int count = countByC_T(classNameId, templateId);
17235    
17236                    if (count == 0) {
17237                            return null;
17238                    }
17239    
17240                    List<JournalArticle> list = findByC_T(classNameId, templateId,
17241                                    count - 1, count, orderByComparator);
17242    
17243                    if (!list.isEmpty()) {
17244                            return list.get(0);
17245                    }
17246    
17247                    return null;
17248            }
17249    
17250            /**
17251             * Returns the journal articles before and after the current journal article in the ordered set where classNameId = &#63; and templateId = &#63;.
17252             *
17253             * @param id the primary key of the current journal article
17254             * @param classNameId the class name ID
17255             * @param templateId the template ID
17256             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17257             * @return the previous, current, and next journal article
17258             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
17259             * @throws SystemException if a system exception occurred
17260             */
17261            @Override
17262            public JournalArticle[] findByC_T_PrevAndNext(long id, long classNameId,
17263                    String templateId, OrderByComparator orderByComparator)
17264                    throws NoSuchArticleException, SystemException {
17265                    JournalArticle journalArticle = findByPrimaryKey(id);
17266    
17267                    Session session = null;
17268    
17269                    try {
17270                            session = openSession();
17271    
17272                            JournalArticle[] array = new JournalArticleImpl[3];
17273    
17274                            array[0] = getByC_T_PrevAndNext(session, journalArticle,
17275                                            classNameId, templateId, orderByComparator, true);
17276    
17277                            array[1] = journalArticle;
17278    
17279                            array[2] = getByC_T_PrevAndNext(session, journalArticle,
17280                                            classNameId, templateId, orderByComparator, false);
17281    
17282                            return array;
17283                    }
17284                    catch (Exception e) {
17285                            throw processException(e);
17286                    }
17287                    finally {
17288                            closeSession(session);
17289                    }
17290            }
17291    
17292            protected JournalArticle getByC_T_PrevAndNext(Session session,
17293                    JournalArticle journalArticle, long classNameId, String templateId,
17294                    OrderByComparator orderByComparator, boolean previous) {
17295                    StringBundler query = null;
17296    
17297                    if (orderByComparator != null) {
17298                            query = new StringBundler(6 +
17299                                            (orderByComparator.getOrderByFields().length * 6));
17300                    }
17301                    else {
17302                            query = new StringBundler(3);
17303                    }
17304    
17305                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17306    
17307                    query.append(_FINDER_COLUMN_C_T_CLASSNAMEID_2);
17308    
17309                    boolean bindTemplateId = false;
17310    
17311                    if (templateId == null) {
17312                            query.append(_FINDER_COLUMN_C_T_TEMPLATEID_1);
17313                    }
17314                    else if (templateId.equals(StringPool.BLANK)) {
17315                            query.append(_FINDER_COLUMN_C_T_TEMPLATEID_3);
17316                    }
17317                    else {
17318                            bindTemplateId = true;
17319    
17320                            query.append(_FINDER_COLUMN_C_T_TEMPLATEID_2);
17321                    }
17322    
17323                    if (orderByComparator != null) {
17324                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17325    
17326                            if (orderByConditionFields.length > 0) {
17327                                    query.append(WHERE_AND);
17328                            }
17329    
17330                            for (int i = 0; i < orderByConditionFields.length; i++) {
17331                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17332                                    query.append(orderByConditionFields[i]);
17333    
17334                                    if ((i + 1) < orderByConditionFields.length) {
17335                                            if (orderByComparator.isAscending() ^ previous) {
17336                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17337                                            }
17338                                            else {
17339                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17340                                            }
17341                                    }
17342                                    else {
17343                                            if (orderByComparator.isAscending() ^ previous) {
17344                                                    query.append(WHERE_GREATER_THAN);
17345                                            }
17346                                            else {
17347                                                    query.append(WHERE_LESSER_THAN);
17348                                            }
17349                                    }
17350                            }
17351    
17352                            query.append(ORDER_BY_CLAUSE);
17353    
17354                            String[] orderByFields = orderByComparator.getOrderByFields();
17355    
17356                            for (int i = 0; i < orderByFields.length; i++) {
17357                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17358                                    query.append(orderByFields[i]);
17359    
17360                                    if ((i + 1) < orderByFields.length) {
17361                                            if (orderByComparator.isAscending() ^ previous) {
17362                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17363                                            }
17364                                            else {
17365                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17366                                            }
17367                                    }
17368                                    else {
17369                                            if (orderByComparator.isAscending() ^ previous) {
17370                                                    query.append(ORDER_BY_ASC);
17371                                            }
17372                                            else {
17373                                                    query.append(ORDER_BY_DESC);
17374                                            }
17375                                    }
17376                            }
17377                    }
17378                    else {
17379                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17380                    }
17381    
17382                    String sql = query.toString();
17383    
17384                    Query q = session.createQuery(sql);
17385    
17386                    q.setFirstResult(0);
17387                    q.setMaxResults(2);
17388    
17389                    QueryPos qPos = QueryPos.getInstance(q);
17390    
17391                    qPos.add(classNameId);
17392    
17393                    if (bindTemplateId) {
17394                            qPos.add(templateId);
17395                    }
17396    
17397                    if (orderByComparator != null) {
17398                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
17399    
17400                            for (Object value : values) {
17401                                    qPos.add(value);
17402                            }
17403                    }
17404    
17405                    List<JournalArticle> list = q.list();
17406    
17407                    if (list.size() == 2) {
17408                            return list.get(1);
17409                    }
17410                    else {
17411                            return null;
17412                    }
17413            }
17414    
17415            /**
17416             * Removes all the journal articles where classNameId = &#63; and templateId = &#63; from the database.
17417             *
17418             * @param classNameId the class name ID
17419             * @param templateId the template ID
17420             * @throws SystemException if a system exception occurred
17421             */
17422            @Override
17423            public void removeByC_T(long classNameId, String templateId)
17424                    throws SystemException {
17425                    for (JournalArticle journalArticle : findByC_T(classNameId, templateId,
17426                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
17427                            remove(journalArticle);
17428                    }
17429            }
17430    
17431            /**
17432             * Returns the number of journal articles where classNameId = &#63; and templateId = &#63;.
17433             *
17434             * @param classNameId the class name ID
17435             * @param templateId the template ID
17436             * @return the number of matching journal articles
17437             * @throws SystemException if a system exception occurred
17438             */
17439            @Override
17440            public int countByC_T(long classNameId, String templateId)
17441                    throws SystemException {
17442                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_T;
17443    
17444                    Object[] finderArgs = new Object[] { classNameId, templateId };
17445    
17446                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
17447                                    this);
17448    
17449                    if (count == null) {
17450                            StringBundler query = new StringBundler(3);
17451    
17452                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17453    
17454                            query.append(_FINDER_COLUMN_C_T_CLASSNAMEID_2);
17455    
17456                            boolean bindTemplateId = false;
17457    
17458                            if (templateId == null) {
17459                                    query.append(_FINDER_COLUMN_C_T_TEMPLATEID_1);
17460                            }
17461                            else if (templateId.equals(StringPool.BLANK)) {
17462                                    query.append(_FINDER_COLUMN_C_T_TEMPLATEID_3);
17463                            }
17464                            else {
17465                                    bindTemplateId = true;
17466    
17467                                    query.append(_FINDER_COLUMN_C_T_TEMPLATEID_2);
17468                            }
17469    
17470                            String sql = query.toString();
17471    
17472                            Session session = null;
17473    
17474                            try {
17475                                    session = openSession();
17476    
17477                                    Query q = session.createQuery(sql);
17478    
17479                                    QueryPos qPos = QueryPos.getInstance(q);
17480    
17481                                    qPos.add(classNameId);
17482    
17483                                    if (bindTemplateId) {
17484                                            qPos.add(templateId);
17485                                    }
17486    
17487                                    count = (Long)q.uniqueResult();
17488    
17489                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
17490                            }
17491                            catch (Exception e) {
17492                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17493    
17494                                    throw processException(e);
17495                            }
17496                            finally {
17497                                    closeSession(session);
17498                            }
17499                    }
17500    
17501                    return count.intValue();
17502            }
17503    
17504            private static final String _FINDER_COLUMN_C_T_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
17505            private static final String _FINDER_COLUMN_C_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
17506            private static final String _FINDER_COLUMN_C_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
17507            private static final String _FINDER_COLUMN_C_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = '')";
17508            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17509                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
17510                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
17511                            "findByLtD_S",
17512                            new String[] {
17513                                    Date.class.getName(), Integer.class.getName(),
17514                                    
17515                            Integer.class.getName(), Integer.class.getName(),
17516                                    OrderByComparator.class.getName()
17517                            });
17518            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17519                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
17520                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByLtD_S",
17521                            new String[] { Date.class.getName(), Integer.class.getName() });
17522    
17523            /**
17524             * Returns all the journal articles where displayDate &lt; &#63; and status = &#63;.
17525             *
17526             * @param displayDate the display date
17527             * @param status the status
17528             * @return the matching journal articles
17529             * @throws SystemException if a system exception occurred
17530             */
17531            @Override
17532            public List<JournalArticle> findByLtD_S(Date displayDate, int status)
17533                    throws SystemException {
17534                    return findByLtD_S(displayDate, status, QueryUtil.ALL_POS,
17535                            QueryUtil.ALL_POS, null);
17536            }
17537    
17538            /**
17539             * Returns a range of all the journal articles where displayDate &lt; &#63; and status = &#63;.
17540             *
17541             * <p>
17542             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17543             * </p>
17544             *
17545             * @param displayDate the display date
17546             * @param status the status
17547             * @param start the lower bound of the range of journal articles
17548             * @param end the upper bound of the range of journal articles (not inclusive)
17549             * @return the range of matching journal articles
17550             * @throws SystemException if a system exception occurred
17551             */
17552            @Override
17553            public List<JournalArticle> findByLtD_S(Date displayDate, int status,
17554                    int start, int end) throws SystemException {
17555                    return findByLtD_S(displayDate, status, start, end, null);
17556            }
17557    
17558            /**
17559             * Returns an ordered range of all the journal articles where displayDate &lt; &#63; and status = &#63;.
17560             *
17561             * <p>
17562             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17563             * </p>
17564             *
17565             * @param displayDate the display date
17566             * @param status the status
17567             * @param start the lower bound of the range of journal articles
17568             * @param end the upper bound of the range of journal articles (not inclusive)
17569             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17570             * @return the ordered range of matching journal articles
17571             * @throws SystemException if a system exception occurred
17572             */
17573            @Override
17574            public List<JournalArticle> findByLtD_S(Date displayDate, int status,
17575                    int start, int end, OrderByComparator orderByComparator)
17576                    throws SystemException {
17577                    boolean pagination = true;
17578                    FinderPath finderPath = null;
17579                    Object[] finderArgs = null;
17580    
17581                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S;
17582                    finderArgs = new Object[] {
17583                                    displayDate, status,
17584                                    
17585                                    start, end, orderByComparator
17586                            };
17587    
17588                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
17589                                    finderArgs, this);
17590    
17591                    if ((list != null) && !list.isEmpty()) {
17592                            for (JournalArticle journalArticle : list) {
17593                                    if ((displayDate.getTime() <= journalArticle.getDisplayDate()
17594                                                                                                                                    .getTime()) ||
17595                                                    (status != journalArticle.getStatus())) {
17596                                            list = null;
17597    
17598                                            break;
17599                                    }
17600                            }
17601                    }
17602    
17603                    if (list == null) {
17604                            StringBundler query = null;
17605    
17606                            if (orderByComparator != null) {
17607                                    query = new StringBundler(4 +
17608                                                    (orderByComparator.getOrderByFields().length * 3));
17609                            }
17610                            else {
17611                                    query = new StringBundler(4);
17612                            }
17613    
17614                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17615    
17616                            boolean bindDisplayDate = false;
17617    
17618                            if (displayDate == null) {
17619                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
17620                            }
17621                            else {
17622                                    bindDisplayDate = true;
17623    
17624                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
17625                            }
17626    
17627                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
17628    
17629                            if (orderByComparator != null) {
17630                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17631                                            orderByComparator);
17632                            }
17633                            else
17634                             if (pagination) {
17635                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17636                            }
17637    
17638                            String sql = query.toString();
17639    
17640                            Session session = null;
17641    
17642                            try {
17643                                    session = openSession();
17644    
17645                                    Query q = session.createQuery(sql);
17646    
17647                                    QueryPos qPos = QueryPos.getInstance(q);
17648    
17649                                    if (bindDisplayDate) {
17650                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
17651                                    }
17652    
17653                                    qPos.add(status);
17654    
17655                                    if (!pagination) {
17656                                            list = (List<JournalArticle>)QueryUtil.list(q,
17657                                                            getDialect(), start, end, false);
17658    
17659                                            Collections.sort(list);
17660    
17661                                            list = new UnmodifiableList<JournalArticle>(list);
17662                                    }
17663                                    else {
17664                                            list = (List<JournalArticle>)QueryUtil.list(q,
17665                                                            getDialect(), start, end);
17666                                    }
17667    
17668                                    cacheResult(list);
17669    
17670                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
17671                            }
17672                            catch (Exception e) {
17673                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17674    
17675                                    throw processException(e);
17676                            }
17677                            finally {
17678                                    closeSession(session);
17679                            }
17680                    }
17681    
17682                    return list;
17683            }
17684    
17685            /**
17686             * Returns the first journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
17687             *
17688             * @param displayDate the display date
17689             * @param status the status
17690             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17691             * @return the first matching journal article
17692             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
17693             * @throws SystemException if a system exception occurred
17694             */
17695            @Override
17696            public JournalArticle findByLtD_S_First(Date displayDate, int status,
17697                    OrderByComparator orderByComparator)
17698                    throws NoSuchArticleException, SystemException {
17699                    JournalArticle journalArticle = fetchByLtD_S_First(displayDate, status,
17700                                    orderByComparator);
17701    
17702                    if (journalArticle != null) {
17703                            return journalArticle;
17704                    }
17705    
17706                    StringBundler msg = new StringBundler(6);
17707    
17708                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17709    
17710                    msg.append("displayDate=");
17711                    msg.append(displayDate);
17712    
17713                    msg.append(", status=");
17714                    msg.append(status);
17715    
17716                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17717    
17718                    throw new NoSuchArticleException(msg.toString());
17719            }
17720    
17721            /**
17722             * Returns the first journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
17723             *
17724             * @param displayDate the display date
17725             * @param status the status
17726             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17727             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
17728             * @throws SystemException if a system exception occurred
17729             */
17730            @Override
17731            public JournalArticle fetchByLtD_S_First(Date displayDate, int status,
17732                    OrderByComparator orderByComparator) throws SystemException {
17733                    List<JournalArticle> list = findByLtD_S(displayDate, status, 0, 1,
17734                                    orderByComparator);
17735    
17736                    if (!list.isEmpty()) {
17737                            return list.get(0);
17738                    }
17739    
17740                    return null;
17741            }
17742    
17743            /**
17744             * Returns the last journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
17745             *
17746             * @param displayDate the display date
17747             * @param status the status
17748             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17749             * @return the last matching journal article
17750             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
17751             * @throws SystemException if a system exception occurred
17752             */
17753            @Override
17754            public JournalArticle findByLtD_S_Last(Date displayDate, int status,
17755                    OrderByComparator orderByComparator)
17756                    throws NoSuchArticleException, SystemException {
17757                    JournalArticle journalArticle = fetchByLtD_S_Last(displayDate, status,
17758                                    orderByComparator);
17759    
17760                    if (journalArticle != null) {
17761                            return journalArticle;
17762                    }
17763    
17764                    StringBundler msg = new StringBundler(6);
17765    
17766                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17767    
17768                    msg.append("displayDate=");
17769                    msg.append(displayDate);
17770    
17771                    msg.append(", status=");
17772                    msg.append(status);
17773    
17774                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17775    
17776                    throw new NoSuchArticleException(msg.toString());
17777            }
17778    
17779            /**
17780             * Returns the last journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
17781             *
17782             * @param displayDate the display date
17783             * @param status the status
17784             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17785             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
17786             * @throws SystemException if a system exception occurred
17787             */
17788            @Override
17789            public JournalArticle fetchByLtD_S_Last(Date displayDate, int status,
17790                    OrderByComparator orderByComparator) throws SystemException {
17791                    int count = countByLtD_S(displayDate, status);
17792    
17793                    if (count == 0) {
17794                            return null;
17795                    }
17796    
17797                    List<JournalArticle> list = findByLtD_S(displayDate, status, count - 1,
17798                                    count, orderByComparator);
17799    
17800                    if (!list.isEmpty()) {
17801                            return list.get(0);
17802                    }
17803    
17804                    return null;
17805            }
17806    
17807            /**
17808             * Returns the journal articles before and after the current journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
17809             *
17810             * @param id the primary key of the current journal article
17811             * @param displayDate the display date
17812             * @param status the status
17813             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17814             * @return the previous, current, and next journal article
17815             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
17816             * @throws SystemException if a system exception occurred
17817             */
17818            @Override
17819            public JournalArticle[] findByLtD_S_PrevAndNext(long id, Date displayDate,
17820                    int status, OrderByComparator orderByComparator)
17821                    throws NoSuchArticleException, SystemException {
17822                    JournalArticle journalArticle = findByPrimaryKey(id);
17823    
17824                    Session session = null;
17825    
17826                    try {
17827                            session = openSession();
17828    
17829                            JournalArticle[] array = new JournalArticleImpl[3];
17830    
17831                            array[0] = getByLtD_S_PrevAndNext(session, journalArticle,
17832                                            displayDate, status, orderByComparator, true);
17833    
17834                            array[1] = journalArticle;
17835    
17836                            array[2] = getByLtD_S_PrevAndNext(session, journalArticle,
17837                                            displayDate, status, orderByComparator, false);
17838    
17839                            return array;
17840                    }
17841                    catch (Exception e) {
17842                            throw processException(e);
17843                    }
17844                    finally {
17845                            closeSession(session);
17846                    }
17847            }
17848    
17849            protected JournalArticle getByLtD_S_PrevAndNext(Session session,
17850                    JournalArticle journalArticle, Date displayDate, int status,
17851                    OrderByComparator orderByComparator, boolean previous) {
17852                    StringBundler query = null;
17853    
17854                    if (orderByComparator != null) {
17855                            query = new StringBundler(6 +
17856                                            (orderByComparator.getOrderByFields().length * 6));
17857                    }
17858                    else {
17859                            query = new StringBundler(3);
17860                    }
17861    
17862                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17863    
17864                    boolean bindDisplayDate = false;
17865    
17866                    if (displayDate == null) {
17867                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
17868                    }
17869                    else {
17870                            bindDisplayDate = true;
17871    
17872                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
17873                    }
17874    
17875                    query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
17876    
17877                    if (orderByComparator != null) {
17878                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17879    
17880                            if (orderByConditionFields.length > 0) {
17881                                    query.append(WHERE_AND);
17882                            }
17883    
17884                            for (int i = 0; i < orderByConditionFields.length; i++) {
17885                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17886                                    query.append(orderByConditionFields[i]);
17887    
17888                                    if ((i + 1) < orderByConditionFields.length) {
17889                                            if (orderByComparator.isAscending() ^ previous) {
17890                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17891                                            }
17892                                            else {
17893                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17894                                            }
17895                                    }
17896                                    else {
17897                                            if (orderByComparator.isAscending() ^ previous) {
17898                                                    query.append(WHERE_GREATER_THAN);
17899                                            }
17900                                            else {
17901                                                    query.append(WHERE_LESSER_THAN);
17902                                            }
17903                                    }
17904                            }
17905    
17906                            query.append(ORDER_BY_CLAUSE);
17907    
17908                            String[] orderByFields = orderByComparator.getOrderByFields();
17909    
17910                            for (int i = 0; i < orderByFields.length; i++) {
17911                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17912                                    query.append(orderByFields[i]);
17913    
17914                                    if ((i + 1) < orderByFields.length) {
17915                                            if (orderByComparator.isAscending() ^ previous) {
17916                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17917                                            }
17918                                            else {
17919                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17920                                            }
17921                                    }
17922                                    else {
17923                                            if (orderByComparator.isAscending() ^ previous) {
17924                                                    query.append(ORDER_BY_ASC);
17925                                            }
17926                                            else {
17927                                                    query.append(ORDER_BY_DESC);
17928                                            }
17929                                    }
17930                            }
17931                    }
17932                    else {
17933                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17934                    }
17935    
17936                    String sql = query.toString();
17937    
17938                    Query q = session.createQuery(sql);
17939    
17940                    q.setFirstResult(0);
17941                    q.setMaxResults(2);
17942    
17943                    QueryPos qPos = QueryPos.getInstance(q);
17944    
17945                    if (bindDisplayDate) {
17946                            qPos.add(CalendarUtil.getTimestamp(displayDate));
17947                    }
17948    
17949                    qPos.add(status);
17950    
17951                    if (orderByComparator != null) {
17952                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
17953    
17954                            for (Object value : values) {
17955                                    qPos.add(value);
17956                            }
17957                    }
17958    
17959                    List<JournalArticle> list = q.list();
17960    
17961                    if (list.size() == 2) {
17962                            return list.get(1);
17963                    }
17964                    else {
17965                            return null;
17966                    }
17967            }
17968    
17969            /**
17970             * Removes all the journal articles where displayDate &lt; &#63; and status = &#63; from the database.
17971             *
17972             * @param displayDate the display date
17973             * @param status the status
17974             * @throws SystemException if a system exception occurred
17975             */
17976            @Override
17977            public void removeByLtD_S(Date displayDate, int status)
17978                    throws SystemException {
17979                    for (JournalArticle journalArticle : findByLtD_S(displayDate, status,
17980                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
17981                            remove(journalArticle);
17982                    }
17983            }
17984    
17985            /**
17986             * Returns the number of journal articles where displayDate &lt; &#63; and status = &#63;.
17987             *
17988             * @param displayDate the display date
17989             * @param status the status
17990             * @return the number of matching journal articles
17991             * @throws SystemException if a system exception occurred
17992             */
17993            @Override
17994            public int countByLtD_S(Date displayDate, int status)
17995                    throws SystemException {
17996                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S;
17997    
17998                    Object[] finderArgs = new Object[] { displayDate, status };
17999    
18000                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
18001                                    this);
18002    
18003                    if (count == null) {
18004                            StringBundler query = new StringBundler(3);
18005    
18006                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
18007    
18008                            boolean bindDisplayDate = false;
18009    
18010                            if (displayDate == null) {
18011                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
18012                            }
18013                            else {
18014                                    bindDisplayDate = true;
18015    
18016                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
18017                            }
18018    
18019                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
18020    
18021                            String sql = query.toString();
18022    
18023                            Session session = null;
18024    
18025                            try {
18026                                    session = openSession();
18027    
18028                                    Query q = session.createQuery(sql);
18029    
18030                                    QueryPos qPos = QueryPos.getInstance(q);
18031    
18032                                    if (bindDisplayDate) {
18033                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
18034                                    }
18035    
18036                                    qPos.add(status);
18037    
18038                                    count = (Long)q.uniqueResult();
18039    
18040                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
18041                            }
18042                            catch (Exception e) {
18043                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18044    
18045                                    throw processException(e);
18046                            }
18047                            finally {
18048                                    closeSession(session);
18049                            }
18050                    }
18051    
18052                    return count.intValue();
18053            }
18054    
18055            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_1 = "journalArticle.displayDate < NULL AND ";
18056            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_2 = "journalArticle.displayDate < ? AND ";
18057            private static final String _FINDER_COLUMN_LTD_S_STATUS_2 = "journalArticle.status = ?";
18058            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18059                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
18060                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
18061                            "findByR_I_S",
18062                            new String[] {
18063                                    Long.class.getName(), Boolean.class.getName(),
18064                                    Integer.class.getName(),
18065                                    
18066                            Integer.class.getName(), Integer.class.getName(),
18067                                    OrderByComparator.class.getName()
18068                            });
18069            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18070                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
18071                            JournalArticleImpl.class,
18072                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_I_S",
18073                            new String[] {
18074                                    Long.class.getName(), Boolean.class.getName(),
18075                                    Integer.class.getName()
18076                            },
18077                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
18078                            JournalArticleModelImpl.INDEXABLE_COLUMN_BITMASK |
18079                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
18080                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
18081                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
18082            public static final FinderPath FINDER_PATH_COUNT_BY_R_I_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18083                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
18084                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_I_S",
18085                            new String[] {
18086                                    Long.class.getName(), Boolean.class.getName(),
18087                                    Integer.class.getName()
18088                            });
18089            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_I_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18090                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
18091                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByR_I_S",
18092                            new String[] {
18093                                    Long.class.getName(), Boolean.class.getName(),
18094                                    Integer.class.getName()
18095                            });
18096    
18097            /**
18098             * Returns all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
18099             *
18100             * @param resourcePrimKey the resource prim key
18101             * @param indexable the indexable
18102             * @param status the status
18103             * @return the matching journal articles
18104             * @throws SystemException if a system exception occurred
18105             */
18106            @Override
18107            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
18108                    boolean indexable, int status) throws SystemException {
18109                    return findByR_I_S(resourcePrimKey, indexable, status,
18110                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
18111            }
18112    
18113            /**
18114             * Returns a range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
18115             *
18116             * <p>
18117             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18118             * </p>
18119             *
18120             * @param resourcePrimKey the resource prim key
18121             * @param indexable the indexable
18122             * @param status the status
18123             * @param start the lower bound of the range of journal articles
18124             * @param end the upper bound of the range of journal articles (not inclusive)
18125             * @return the range of matching journal articles
18126             * @throws SystemException if a system exception occurred
18127             */
18128            @Override
18129            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
18130                    boolean indexable, int status, int start, int end)
18131                    throws SystemException {
18132                    return findByR_I_S(resourcePrimKey, indexable, status, start, end, null);
18133            }
18134    
18135            /**
18136             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
18137             *
18138             * <p>
18139             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18140             * </p>
18141             *
18142             * @param resourcePrimKey the resource prim key
18143             * @param indexable the indexable
18144             * @param status the status
18145             * @param start the lower bound of the range of journal articles
18146             * @param end the upper bound of the range of journal articles (not inclusive)
18147             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18148             * @return the ordered range of matching journal articles
18149             * @throws SystemException if a system exception occurred
18150             */
18151            @Override
18152            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
18153                    boolean indexable, int status, int start, int end,
18154                    OrderByComparator orderByComparator) throws SystemException {
18155                    boolean pagination = true;
18156                    FinderPath finderPath = null;
18157                    Object[] finderArgs = null;
18158    
18159                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
18160                                    (orderByComparator == null)) {
18161                            pagination = false;
18162                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S;
18163                            finderArgs = new Object[] { resourcePrimKey, indexable, status };
18164                    }
18165                    else {
18166                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S;
18167                            finderArgs = new Object[] {
18168                                            resourcePrimKey, indexable, status,
18169                                            
18170                                            start, end, orderByComparator
18171                                    };
18172                    }
18173    
18174                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
18175                                    finderArgs, this);
18176    
18177                    if ((list != null) && !list.isEmpty()) {
18178                            for (JournalArticle journalArticle : list) {
18179                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
18180                                                    (indexable != journalArticle.getIndexable()) ||
18181                                                    (status != journalArticle.getStatus())) {
18182                                            list = null;
18183    
18184                                            break;
18185                                    }
18186                            }
18187                    }
18188    
18189                    if (list == null) {
18190                            StringBundler query = null;
18191    
18192                            if (orderByComparator != null) {
18193                                    query = new StringBundler(5 +
18194                                                    (orderByComparator.getOrderByFields().length * 3));
18195                            }
18196                            else {
18197                                    query = new StringBundler(5);
18198                            }
18199    
18200                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
18201    
18202                            query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2);
18203    
18204                            query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_2);
18205    
18206                            query.append(_FINDER_COLUMN_R_I_S_STATUS_2);
18207    
18208                            if (orderByComparator != null) {
18209                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18210                                            orderByComparator);
18211                            }
18212                            else
18213                             if (pagination) {
18214                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18215                            }
18216    
18217                            String sql = query.toString();
18218    
18219                            Session session = null;
18220    
18221                            try {
18222                                    session = openSession();
18223    
18224                                    Query q = session.createQuery(sql);
18225    
18226                                    QueryPos qPos = QueryPos.getInstance(q);
18227    
18228                                    qPos.add(resourcePrimKey);
18229    
18230                                    qPos.add(indexable);
18231    
18232                                    qPos.add(status);
18233    
18234                                    if (!pagination) {
18235                                            list = (List<JournalArticle>)QueryUtil.list(q,
18236                                                            getDialect(), start, end, false);
18237    
18238                                            Collections.sort(list);
18239    
18240                                            list = new UnmodifiableList<JournalArticle>(list);
18241                                    }
18242                                    else {
18243                                            list = (List<JournalArticle>)QueryUtil.list(q,
18244                                                            getDialect(), start, end);
18245                                    }
18246    
18247                                    cacheResult(list);
18248    
18249                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
18250                            }
18251                            catch (Exception e) {
18252                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18253    
18254                                    throw processException(e);
18255                            }
18256                            finally {
18257                                    closeSession(session);
18258                            }
18259                    }
18260    
18261                    return list;
18262            }
18263    
18264            /**
18265             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
18266             *
18267             * @param resourcePrimKey the resource prim key
18268             * @param indexable the indexable
18269             * @param status the status
18270             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18271             * @return the first matching journal article
18272             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
18273             * @throws SystemException if a system exception occurred
18274             */
18275            @Override
18276            public JournalArticle findByR_I_S_First(long resourcePrimKey,
18277                    boolean indexable, int status, OrderByComparator orderByComparator)
18278                    throws NoSuchArticleException, SystemException {
18279                    JournalArticle journalArticle = fetchByR_I_S_First(resourcePrimKey,
18280                                    indexable, status, orderByComparator);
18281    
18282                    if (journalArticle != null) {
18283                            return journalArticle;
18284                    }
18285    
18286                    StringBundler msg = new StringBundler(8);
18287    
18288                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
18289    
18290                    msg.append("resourcePrimKey=");
18291                    msg.append(resourcePrimKey);
18292    
18293                    msg.append(", indexable=");
18294                    msg.append(indexable);
18295    
18296                    msg.append(", status=");
18297                    msg.append(status);
18298    
18299                    msg.append(StringPool.CLOSE_CURLY_BRACE);
18300    
18301                    throw new NoSuchArticleException(msg.toString());
18302            }
18303    
18304            /**
18305             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
18306             *
18307             * @param resourcePrimKey the resource prim key
18308             * @param indexable the indexable
18309             * @param status the status
18310             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18311             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
18312             * @throws SystemException if a system exception occurred
18313             */
18314            @Override
18315            public JournalArticle fetchByR_I_S_First(long resourcePrimKey,
18316                    boolean indexable, int status, OrderByComparator orderByComparator)
18317                    throws SystemException {
18318                    List<JournalArticle> list = findByR_I_S(resourcePrimKey, indexable,
18319                                    status, 0, 1, orderByComparator);
18320    
18321                    if (!list.isEmpty()) {
18322                            return list.get(0);
18323                    }
18324    
18325                    return null;
18326            }
18327    
18328            /**
18329             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
18330             *
18331             * @param resourcePrimKey the resource prim key
18332             * @param indexable the indexable
18333             * @param status the status
18334             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18335             * @return the last matching journal article
18336             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
18337             * @throws SystemException if a system exception occurred
18338             */
18339            @Override
18340            public JournalArticle findByR_I_S_Last(long resourcePrimKey,
18341                    boolean indexable, int status, OrderByComparator orderByComparator)
18342                    throws NoSuchArticleException, SystemException {
18343                    JournalArticle journalArticle = fetchByR_I_S_Last(resourcePrimKey,
18344                                    indexable, status, orderByComparator);
18345    
18346                    if (journalArticle != null) {
18347                            return journalArticle;
18348                    }
18349    
18350                    StringBundler msg = new StringBundler(8);
18351    
18352                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
18353    
18354                    msg.append("resourcePrimKey=");
18355                    msg.append(resourcePrimKey);
18356    
18357                    msg.append(", indexable=");
18358                    msg.append(indexable);
18359    
18360                    msg.append(", status=");
18361                    msg.append(status);
18362    
18363                    msg.append(StringPool.CLOSE_CURLY_BRACE);
18364    
18365                    throw new NoSuchArticleException(msg.toString());
18366            }
18367    
18368            /**
18369             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
18370             *
18371             * @param resourcePrimKey the resource prim key
18372             * @param indexable the indexable
18373             * @param status the status
18374             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18375             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
18376             * @throws SystemException if a system exception occurred
18377             */
18378            @Override
18379            public JournalArticle fetchByR_I_S_Last(long resourcePrimKey,
18380                    boolean indexable, int status, OrderByComparator orderByComparator)
18381                    throws SystemException {
18382                    int count = countByR_I_S(resourcePrimKey, indexable, status);
18383    
18384                    if (count == 0) {
18385                            return null;
18386                    }
18387    
18388                    List<JournalArticle> list = findByR_I_S(resourcePrimKey, indexable,
18389                                    status, count - 1, count, orderByComparator);
18390    
18391                    if (!list.isEmpty()) {
18392                            return list.get(0);
18393                    }
18394    
18395                    return null;
18396            }
18397    
18398            /**
18399             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
18400             *
18401             * @param id the primary key of the current journal article
18402             * @param resourcePrimKey the resource prim key
18403             * @param indexable the indexable
18404             * @param status the status
18405             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18406             * @return the previous, current, and next journal article
18407             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
18408             * @throws SystemException if a system exception occurred
18409             */
18410            @Override
18411            public JournalArticle[] findByR_I_S_PrevAndNext(long id,
18412                    long resourcePrimKey, boolean indexable, int status,
18413                    OrderByComparator orderByComparator)
18414                    throws NoSuchArticleException, SystemException {
18415                    JournalArticle journalArticle = findByPrimaryKey(id);
18416    
18417                    Session session = null;
18418    
18419                    try {
18420                            session = openSession();
18421    
18422                            JournalArticle[] array = new JournalArticleImpl[3];
18423    
18424                            array[0] = getByR_I_S_PrevAndNext(session, journalArticle,
18425                                            resourcePrimKey, indexable, status, orderByComparator, true);
18426    
18427                            array[1] = journalArticle;
18428    
18429                            array[2] = getByR_I_S_PrevAndNext(session, journalArticle,
18430                                            resourcePrimKey, indexable, status, orderByComparator, false);
18431    
18432                            return array;
18433                    }
18434                    catch (Exception e) {
18435                            throw processException(e);
18436                    }
18437                    finally {
18438                            closeSession(session);
18439                    }
18440            }
18441    
18442            protected JournalArticle getByR_I_S_PrevAndNext(Session session,
18443                    JournalArticle journalArticle, long resourcePrimKey, boolean indexable,
18444                    int status, OrderByComparator orderByComparator, boolean previous) {
18445                    StringBundler query = null;
18446    
18447                    if (orderByComparator != null) {
18448                            query = new StringBundler(6 +
18449                                            (orderByComparator.getOrderByFields().length * 6));
18450                    }
18451                    else {
18452                            query = new StringBundler(3);
18453                    }
18454    
18455                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
18456    
18457                    query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2);
18458    
18459                    query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_2);
18460    
18461                    query.append(_FINDER_COLUMN_R_I_S_STATUS_2);
18462    
18463                    if (orderByComparator != null) {
18464                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
18465    
18466                            if (orderByConditionFields.length > 0) {
18467                                    query.append(WHERE_AND);
18468                            }
18469    
18470                            for (int i = 0; i < orderByConditionFields.length; i++) {
18471                                    query.append(_ORDER_BY_ENTITY_ALIAS);
18472                                    query.append(orderByConditionFields[i]);
18473    
18474                                    if ((i + 1) < orderByConditionFields.length) {
18475                                            if (orderByComparator.isAscending() ^ previous) {
18476                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
18477                                            }
18478                                            else {
18479                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
18480                                            }
18481                                    }
18482                                    else {
18483                                            if (orderByComparator.isAscending() ^ previous) {
18484                                                    query.append(WHERE_GREATER_THAN);
18485                                            }
18486                                            else {
18487                                                    query.append(WHERE_LESSER_THAN);
18488                                            }
18489                                    }
18490                            }
18491    
18492                            query.append(ORDER_BY_CLAUSE);
18493    
18494                            String[] orderByFields = orderByComparator.getOrderByFields();
18495    
18496                            for (int i = 0; i < orderByFields.length; i++) {
18497                                    query.append(_ORDER_BY_ENTITY_ALIAS);
18498                                    query.append(orderByFields[i]);
18499    
18500                                    if ((i + 1) < orderByFields.length) {
18501                                            if (orderByComparator.isAscending() ^ previous) {
18502                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
18503                                            }
18504                                            else {
18505                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
18506                                            }
18507                                    }
18508                                    else {
18509                                            if (orderByComparator.isAscending() ^ previous) {
18510                                                    query.append(ORDER_BY_ASC);
18511                                            }
18512                                            else {
18513                                                    query.append(ORDER_BY_DESC);
18514                                            }
18515                                    }
18516                            }
18517                    }
18518                    else {
18519                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18520                    }
18521    
18522                    String sql = query.toString();
18523    
18524                    Query q = session.createQuery(sql);
18525    
18526                    q.setFirstResult(0);
18527                    q.setMaxResults(2);
18528    
18529                    QueryPos qPos = QueryPos.getInstance(q);
18530    
18531                    qPos.add(resourcePrimKey);
18532    
18533                    qPos.add(indexable);
18534    
18535                    qPos.add(status);
18536    
18537                    if (orderByComparator != null) {
18538                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
18539    
18540                            for (Object value : values) {
18541                                    qPos.add(value);
18542                            }
18543                    }
18544    
18545                    List<JournalArticle> list = q.list();
18546    
18547                    if (list.size() == 2) {
18548                            return list.get(1);
18549                    }
18550                    else {
18551                            return null;
18552                    }
18553            }
18554    
18555            /**
18556             * Returns all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = any &#63;.
18557             *
18558             * <p>
18559             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18560             * </p>
18561             *
18562             * @param resourcePrimKey the resource prim key
18563             * @param indexable the indexable
18564             * @param statuses the statuses
18565             * @return the matching journal articles
18566             * @throws SystemException if a system exception occurred
18567             */
18568            @Override
18569            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
18570                    boolean indexable, int[] statuses) throws SystemException {
18571                    return findByR_I_S(resourcePrimKey, indexable, statuses,
18572                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
18573            }
18574    
18575            /**
18576             * Returns a range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = any &#63;.
18577             *
18578             * <p>
18579             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18580             * </p>
18581             *
18582             * @param resourcePrimKey the resource prim key
18583             * @param indexable the indexable
18584             * @param statuses the statuses
18585             * @param start the lower bound of the range of journal articles
18586             * @param end the upper bound of the range of journal articles (not inclusive)
18587             * @return the range of matching journal articles
18588             * @throws SystemException if a system exception occurred
18589             */
18590            @Override
18591            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
18592                    boolean indexable, int[] statuses, int start, int end)
18593                    throws SystemException {
18594                    return findByR_I_S(resourcePrimKey, indexable, statuses, start, end,
18595                            null);
18596            }
18597    
18598            /**
18599             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = any &#63;.
18600             *
18601             * <p>
18602             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18603             * </p>
18604             *
18605             * @param resourcePrimKey the resource prim key
18606             * @param indexable the indexable
18607             * @param statuses the statuses
18608             * @param start the lower bound of the range of journal articles
18609             * @param end the upper bound of the range of journal articles (not inclusive)
18610             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18611             * @return the ordered range of matching journal articles
18612             * @throws SystemException if a system exception occurred
18613             */
18614            @Override
18615            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
18616                    boolean indexable, int[] statuses, int start, int end,
18617                    OrderByComparator orderByComparator) throws SystemException {
18618                    if ((statuses != null) && (statuses.length == 1)) {
18619                            return findByR_I_S(resourcePrimKey, indexable, statuses[0], start,
18620                                    end, orderByComparator);
18621                    }
18622    
18623                    boolean pagination = true;
18624                    Object[] finderArgs = null;
18625    
18626                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
18627                                    (orderByComparator == null)) {
18628                            pagination = false;
18629                            finderArgs = new Object[] {
18630                                            resourcePrimKey, indexable, StringUtil.merge(statuses)
18631                                    };
18632                    }
18633                    else {
18634                            finderArgs = new Object[] {
18635                                            resourcePrimKey, indexable, StringUtil.merge(statuses),
18636                                            
18637                                            start, end, orderByComparator
18638                                    };
18639                    }
18640    
18641                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S,
18642                                    finderArgs, this);
18643    
18644                    if ((list != null) && !list.isEmpty()) {
18645                            for (JournalArticle journalArticle : list) {
18646                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
18647                                                    (indexable != journalArticle.getIndexable()) ||
18648                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
18649                                            list = null;
18650    
18651                                            break;
18652                                    }
18653                            }
18654                    }
18655    
18656                    if (list == null) {
18657                            StringBundler query = new StringBundler();
18658    
18659                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
18660    
18661                            boolean conjunctionable = false;
18662    
18663                            if (conjunctionable) {
18664                                    query.append(WHERE_AND);
18665                            }
18666    
18667                            query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_5);
18668    
18669                            conjunctionable = true;
18670    
18671                            if (conjunctionable) {
18672                                    query.append(WHERE_AND);
18673                            }
18674    
18675                            query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_5);
18676    
18677                            conjunctionable = true;
18678    
18679                            if ((statuses == null) || (statuses.length > 0)) {
18680                                    if (conjunctionable) {
18681                                            query.append(WHERE_AND);
18682                                    }
18683    
18684                                    query.append(StringPool.OPEN_PARENTHESIS);
18685    
18686                                    for (int i = 0; i < statuses.length; i++) {
18687                                            query.append(_FINDER_COLUMN_R_I_S_STATUS_5);
18688    
18689                                            if ((i + 1) < statuses.length) {
18690                                                    query.append(WHERE_OR);
18691                                            }
18692                                    }
18693    
18694                                    query.append(StringPool.CLOSE_PARENTHESIS);
18695    
18696                                    conjunctionable = true;
18697                            }
18698    
18699                            if (orderByComparator != null) {
18700                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18701                                            orderByComparator);
18702                            }
18703                            else
18704                             if (pagination) {
18705                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18706                            }
18707    
18708                            String sql = query.toString();
18709    
18710                            Session session = null;
18711    
18712                            try {
18713                                    session = openSession();
18714    
18715                                    Query q = session.createQuery(sql);
18716    
18717                                    QueryPos qPos = QueryPos.getInstance(q);
18718    
18719                                    qPos.add(resourcePrimKey);
18720    
18721                                    qPos.add(indexable);
18722    
18723                                    if (statuses != null) {
18724                                            qPos.add(statuses);
18725                                    }
18726    
18727                                    if (!pagination) {
18728                                            list = (List<JournalArticle>)QueryUtil.list(q,
18729                                                            getDialect(), start, end, false);
18730    
18731                                            Collections.sort(list);
18732    
18733                                            list = new UnmodifiableList<JournalArticle>(list);
18734                                    }
18735                                    else {
18736                                            list = (List<JournalArticle>)QueryUtil.list(q,
18737                                                            getDialect(), start, end);
18738                                    }
18739    
18740                                    cacheResult(list);
18741    
18742                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S,
18743                                            finderArgs, list);
18744                            }
18745                            catch (Exception e) {
18746                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S,
18747                                            finderArgs);
18748    
18749                                    throw processException(e);
18750                            }
18751                            finally {
18752                                    closeSession(session);
18753                            }
18754                    }
18755    
18756                    return list;
18757            }
18758    
18759            /**
18760             * Removes all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63; from the database.
18761             *
18762             * @param resourcePrimKey the resource prim key
18763             * @param indexable the indexable
18764             * @param status the status
18765             * @throws SystemException if a system exception occurred
18766             */
18767            @Override
18768            public void removeByR_I_S(long resourcePrimKey, boolean indexable,
18769                    int status) throws SystemException {
18770                    for (JournalArticle journalArticle : findByR_I_S(resourcePrimKey,
18771                                    indexable, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
18772                            remove(journalArticle);
18773                    }
18774            }
18775    
18776            /**
18777             * Returns the number of journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
18778             *
18779             * @param resourcePrimKey the resource prim key
18780             * @param indexable the indexable
18781             * @param status the status
18782             * @return the number of matching journal articles
18783             * @throws SystemException if a system exception occurred
18784             */
18785            @Override
18786            public int countByR_I_S(long resourcePrimKey, boolean indexable, int status)
18787                    throws SystemException {
18788                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_I_S;
18789    
18790                    Object[] finderArgs = new Object[] { resourcePrimKey, indexable, status };
18791    
18792                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
18793                                    this);
18794    
18795                    if (count == null) {
18796                            StringBundler query = new StringBundler(4);
18797    
18798                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
18799    
18800                            query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2);
18801    
18802                            query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_2);
18803    
18804                            query.append(_FINDER_COLUMN_R_I_S_STATUS_2);
18805    
18806                            String sql = query.toString();
18807    
18808                            Session session = null;
18809    
18810                            try {
18811                                    session = openSession();
18812    
18813                                    Query q = session.createQuery(sql);
18814    
18815                                    QueryPos qPos = QueryPos.getInstance(q);
18816    
18817                                    qPos.add(resourcePrimKey);
18818    
18819                                    qPos.add(indexable);
18820    
18821                                    qPos.add(status);
18822    
18823                                    count = (Long)q.uniqueResult();
18824    
18825                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
18826                            }
18827                            catch (Exception e) {
18828                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18829    
18830                                    throw processException(e);
18831                            }
18832                            finally {
18833                                    closeSession(session);
18834                            }
18835                    }
18836    
18837                    return count.intValue();
18838            }
18839    
18840            /**
18841             * Returns the number of journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = any &#63;.
18842             *
18843             * @param resourcePrimKey the resource prim key
18844             * @param indexable the indexable
18845             * @param statuses the statuses
18846             * @return the number of matching journal articles
18847             * @throws SystemException if a system exception occurred
18848             */
18849            @Override
18850            public int countByR_I_S(long resourcePrimKey, boolean indexable,
18851                    int[] statuses) throws SystemException {
18852                    Object[] finderArgs = new Object[] {
18853                                    resourcePrimKey, indexable, StringUtil.merge(statuses)
18854                            };
18855    
18856                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_I_S,
18857                                    finderArgs, this);
18858    
18859                    if (count == null) {
18860                            StringBundler query = new StringBundler();
18861    
18862                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
18863    
18864                            boolean conjunctionable = false;
18865    
18866                            if (conjunctionable) {
18867                                    query.append(WHERE_AND);
18868                            }
18869    
18870                            query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_5);
18871    
18872                            conjunctionable = true;
18873    
18874                            if (conjunctionable) {
18875                                    query.append(WHERE_AND);
18876                            }
18877    
18878                            query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_5);
18879    
18880                            conjunctionable = true;
18881    
18882                            if ((statuses == null) || (statuses.length > 0)) {
18883                                    if (conjunctionable) {
18884                                            query.append(WHERE_AND);
18885                                    }
18886    
18887                                    query.append(StringPool.OPEN_PARENTHESIS);
18888    
18889                                    for (int i = 0; i < statuses.length; i++) {
18890                                            query.append(_FINDER_COLUMN_R_I_S_STATUS_5);
18891    
18892                                            if ((i + 1) < statuses.length) {
18893                                                    query.append(WHERE_OR);
18894                                            }
18895                                    }
18896    
18897                                    query.append(StringPool.CLOSE_PARENTHESIS);
18898    
18899                                    conjunctionable = true;
18900                            }
18901    
18902                            String sql = query.toString();
18903    
18904                            Session session = null;
18905    
18906                            try {
18907                                    session = openSession();
18908    
18909                                    Query q = session.createQuery(sql);
18910    
18911                                    QueryPos qPos = QueryPos.getInstance(q);
18912    
18913                                    qPos.add(resourcePrimKey);
18914    
18915                                    qPos.add(indexable);
18916    
18917                                    if (statuses != null) {
18918                                            qPos.add(statuses);
18919                                    }
18920    
18921                                    count = (Long)q.uniqueResult();
18922    
18923                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_I_S,
18924                                            finderArgs, count);
18925                            }
18926                            catch (Exception e) {
18927                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_I_S,
18928                                            finderArgs);
18929    
18930                                    throw processException(e);
18931                            }
18932                            finally {
18933                                    closeSession(session);
18934                            }
18935                    }
18936    
18937                    return count.intValue();
18938            }
18939    
18940            private static final String _FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2 = "journalArticle.resourcePrimKey = ? AND ";
18941            private static final String _FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_5 = "(" +
18942                    removeConjunction(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2) + ")";
18943            private static final String _FINDER_COLUMN_R_I_S_INDEXABLE_2 = "journalArticle.indexable = ? AND ";
18944            private static final String _FINDER_COLUMN_R_I_S_INDEXABLE_5 = "(" +
18945                    removeConjunction(_FINDER_COLUMN_R_I_S_INDEXABLE_2) + ")";
18946            private static final String _FINDER_COLUMN_R_I_S_STATUS_2 = "journalArticle.status = ?";
18947            private static final String _FINDER_COLUMN_R_I_S_STATUS_5 = "(" +
18948                    removeConjunction(_FINDER_COLUMN_R_I_S_STATUS_2) + ")";
18949            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18950                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
18951                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
18952                            "findByG_U_C",
18953                            new String[] {
18954                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
18955                                    
18956                            Integer.class.getName(), Integer.class.getName(),
18957                                    OrderByComparator.class.getName()
18958                            });
18959            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18960                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
18961                            JournalArticleImpl.class,
18962                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_C",
18963                            new String[] {
18964                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
18965                            },
18966                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
18967                            JournalArticleModelImpl.USERID_COLUMN_BITMASK |
18968                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
18969                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
18970                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
18971            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18972                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
18973                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_C",
18974                            new String[] {
18975                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
18976                            });
18977    
18978            /**
18979             * Returns all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18980             *
18981             * @param groupId the group ID
18982             * @param userId the user ID
18983             * @param classNameId the class name ID
18984             * @return the matching journal articles
18985             * @throws SystemException if a system exception occurred
18986             */
18987            @Override
18988            public List<JournalArticle> findByG_U_C(long groupId, long userId,
18989                    long classNameId) throws SystemException {
18990                    return findByG_U_C(groupId, userId, classNameId, QueryUtil.ALL_POS,
18991                            QueryUtil.ALL_POS, null);
18992            }
18993    
18994            /**
18995             * Returns a range of all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18996             *
18997             * <p>
18998             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18999             * </p>
19000             *
19001             * @param groupId the group ID
19002             * @param userId the user ID
19003             * @param classNameId the class name ID
19004             * @param start the lower bound of the range of journal articles
19005             * @param end the upper bound of the range of journal articles (not inclusive)
19006             * @return the range of matching journal articles
19007             * @throws SystemException if a system exception occurred
19008             */
19009            @Override
19010            public List<JournalArticle> findByG_U_C(long groupId, long userId,
19011                    long classNameId, int start, int end) throws SystemException {
19012                    return findByG_U_C(groupId, userId, classNameId, start, end, null);
19013            }
19014    
19015            /**
19016             * Returns an ordered range of all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
19017             *
19018             * <p>
19019             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19020             * </p>
19021             *
19022             * @param groupId the group ID
19023             * @param userId the user ID
19024             * @param classNameId the class name ID
19025             * @param start the lower bound of the range of journal articles
19026             * @param end the upper bound of the range of journal articles (not inclusive)
19027             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19028             * @return the ordered range of matching journal articles
19029             * @throws SystemException if a system exception occurred
19030             */
19031            @Override
19032            public List<JournalArticle> findByG_U_C(long groupId, long userId,
19033                    long classNameId, int start, int end,
19034                    OrderByComparator orderByComparator) throws SystemException {
19035                    boolean pagination = true;
19036                    FinderPath finderPath = null;
19037                    Object[] finderArgs = null;
19038    
19039                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
19040                                    (orderByComparator == null)) {
19041                            pagination = false;
19042                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C;
19043                            finderArgs = new Object[] { groupId, userId, classNameId };
19044                    }
19045                    else {
19046                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_C;
19047                            finderArgs = new Object[] {
19048                                            groupId, userId, classNameId,
19049                                            
19050                                            start, end, orderByComparator
19051                                    };
19052                    }
19053    
19054                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
19055                                    finderArgs, this);
19056    
19057                    if ((list != null) && !list.isEmpty()) {
19058                            for (JournalArticle journalArticle : list) {
19059                                    if ((groupId != journalArticle.getGroupId()) ||
19060                                                    (userId != journalArticle.getUserId()) ||
19061                                                    (classNameId != journalArticle.getClassNameId())) {
19062                                            list = null;
19063    
19064                                            break;
19065                                    }
19066                            }
19067                    }
19068    
19069                    if (list == null) {
19070                            StringBundler query = null;
19071    
19072                            if (orderByComparator != null) {
19073                                    query = new StringBundler(5 +
19074                                                    (orderByComparator.getOrderByFields().length * 3));
19075                            }
19076                            else {
19077                                    query = new StringBundler(5);
19078                            }
19079    
19080                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
19081    
19082                            query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
19083    
19084                            query.append(_FINDER_COLUMN_G_U_C_USERID_2);
19085    
19086                            query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
19087    
19088                            if (orderByComparator != null) {
19089                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
19090                                            orderByComparator);
19091                            }
19092                            else
19093                             if (pagination) {
19094                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19095                            }
19096    
19097                            String sql = query.toString();
19098    
19099                            Session session = null;
19100    
19101                            try {
19102                                    session = openSession();
19103    
19104                                    Query q = session.createQuery(sql);
19105    
19106                                    QueryPos qPos = QueryPos.getInstance(q);
19107    
19108                                    qPos.add(groupId);
19109    
19110                                    qPos.add(userId);
19111    
19112                                    qPos.add(classNameId);
19113    
19114                                    if (!pagination) {
19115                                            list = (List<JournalArticle>)QueryUtil.list(q,
19116                                                            getDialect(), start, end, false);
19117    
19118                                            Collections.sort(list);
19119    
19120                                            list = new UnmodifiableList<JournalArticle>(list);
19121                                    }
19122                                    else {
19123                                            list = (List<JournalArticle>)QueryUtil.list(q,
19124                                                            getDialect(), start, end);
19125                                    }
19126    
19127                                    cacheResult(list);
19128    
19129                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
19130                            }
19131                            catch (Exception e) {
19132                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
19133    
19134                                    throw processException(e);
19135                            }
19136                            finally {
19137                                    closeSession(session);
19138                            }
19139                    }
19140    
19141                    return list;
19142            }
19143    
19144            /**
19145             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
19146             *
19147             * @param groupId the group ID
19148             * @param userId the user ID
19149             * @param classNameId the class name ID
19150             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19151             * @return the first matching journal article
19152             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
19153             * @throws SystemException if a system exception occurred
19154             */
19155            @Override
19156            public JournalArticle findByG_U_C_First(long groupId, long userId,
19157                    long classNameId, OrderByComparator orderByComparator)
19158                    throws NoSuchArticleException, SystemException {
19159                    JournalArticle journalArticle = fetchByG_U_C_First(groupId, userId,
19160                                    classNameId, orderByComparator);
19161    
19162                    if (journalArticle != null) {
19163                            return journalArticle;
19164                    }
19165    
19166                    StringBundler msg = new StringBundler(8);
19167    
19168                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
19169    
19170                    msg.append("groupId=");
19171                    msg.append(groupId);
19172    
19173                    msg.append(", userId=");
19174                    msg.append(userId);
19175    
19176                    msg.append(", classNameId=");
19177                    msg.append(classNameId);
19178    
19179                    msg.append(StringPool.CLOSE_CURLY_BRACE);
19180    
19181                    throw new NoSuchArticleException(msg.toString());
19182            }
19183    
19184            /**
19185             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
19186             *
19187             * @param groupId the group ID
19188             * @param userId the user ID
19189             * @param classNameId the class name ID
19190             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19191             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
19192             * @throws SystemException if a system exception occurred
19193             */
19194            @Override
19195            public JournalArticle fetchByG_U_C_First(long groupId, long userId,
19196                    long classNameId, OrderByComparator orderByComparator)
19197                    throws SystemException {
19198                    List<JournalArticle> list = findByG_U_C(groupId, userId, classNameId,
19199                                    0, 1, orderByComparator);
19200    
19201                    if (!list.isEmpty()) {
19202                            return list.get(0);
19203                    }
19204    
19205                    return null;
19206            }
19207    
19208            /**
19209             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
19210             *
19211             * @param groupId the group ID
19212             * @param userId the user ID
19213             * @param classNameId the class name ID
19214             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19215             * @return the last matching journal article
19216             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
19217             * @throws SystemException if a system exception occurred
19218             */
19219            @Override
19220            public JournalArticle findByG_U_C_Last(long groupId, long userId,
19221                    long classNameId, OrderByComparator orderByComparator)
19222                    throws NoSuchArticleException, SystemException {
19223                    JournalArticle journalArticle = fetchByG_U_C_Last(groupId, userId,
19224                                    classNameId, orderByComparator);
19225    
19226                    if (journalArticle != null) {
19227                            return journalArticle;
19228                    }
19229    
19230                    StringBundler msg = new StringBundler(8);
19231    
19232                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
19233    
19234                    msg.append("groupId=");
19235                    msg.append(groupId);
19236    
19237                    msg.append(", userId=");
19238                    msg.append(userId);
19239    
19240                    msg.append(", classNameId=");
19241                    msg.append(classNameId);
19242    
19243                    msg.append(StringPool.CLOSE_CURLY_BRACE);
19244    
19245                    throw new NoSuchArticleException(msg.toString());
19246            }
19247    
19248            /**
19249             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
19250             *
19251             * @param groupId the group ID
19252             * @param userId the user ID
19253             * @param classNameId the class name ID
19254             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19255             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
19256             * @throws SystemException if a system exception occurred
19257             */
19258            @Override
19259            public JournalArticle fetchByG_U_C_Last(long groupId, long userId,
19260                    long classNameId, OrderByComparator orderByComparator)
19261                    throws SystemException {
19262                    int count = countByG_U_C(groupId, userId, classNameId);
19263    
19264                    if (count == 0) {
19265                            return null;
19266                    }
19267    
19268                    List<JournalArticle> list = findByG_U_C(groupId, userId, classNameId,
19269                                    count - 1, count, orderByComparator);
19270    
19271                    if (!list.isEmpty()) {
19272                            return list.get(0);
19273                    }
19274    
19275                    return null;
19276            }
19277    
19278            /**
19279             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
19280             *
19281             * @param id the primary key of the current journal article
19282             * @param groupId the group ID
19283             * @param userId the user ID
19284             * @param classNameId the class name ID
19285             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19286             * @return the previous, current, and next journal article
19287             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
19288             * @throws SystemException if a system exception occurred
19289             */
19290            @Override
19291            public JournalArticle[] findByG_U_C_PrevAndNext(long id, long groupId,
19292                    long userId, long classNameId, OrderByComparator orderByComparator)
19293                    throws NoSuchArticleException, SystemException {
19294                    JournalArticle journalArticle = findByPrimaryKey(id);
19295    
19296                    Session session = null;
19297    
19298                    try {
19299                            session = openSession();
19300    
19301                            JournalArticle[] array = new JournalArticleImpl[3];
19302    
19303                            array[0] = getByG_U_C_PrevAndNext(session, journalArticle, groupId,
19304                                            userId, classNameId, orderByComparator, true);
19305    
19306                            array[1] = journalArticle;
19307    
19308                            array[2] = getByG_U_C_PrevAndNext(session, journalArticle, groupId,
19309                                            userId, classNameId, orderByComparator, false);
19310    
19311                            return array;
19312                    }
19313                    catch (Exception e) {
19314                            throw processException(e);
19315                    }
19316                    finally {
19317                            closeSession(session);
19318                    }
19319            }
19320    
19321            protected JournalArticle getByG_U_C_PrevAndNext(Session session,
19322                    JournalArticle journalArticle, long groupId, long userId,
19323                    long classNameId, OrderByComparator orderByComparator, boolean previous) {
19324                    StringBundler query = null;
19325    
19326                    if (orderByComparator != null) {
19327                            query = new StringBundler(6 +
19328                                            (orderByComparator.getOrderByFields().length * 6));
19329                    }
19330                    else {
19331                            query = new StringBundler(3);
19332                    }
19333    
19334                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
19335    
19336                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
19337    
19338                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
19339    
19340                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
19341    
19342                    if (orderByComparator != null) {
19343                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
19344    
19345                            if (orderByConditionFields.length > 0) {
19346                                    query.append(WHERE_AND);
19347                            }
19348    
19349                            for (int i = 0; i < orderByConditionFields.length; i++) {
19350                                    query.append(_ORDER_BY_ENTITY_ALIAS);
19351                                    query.append(orderByConditionFields[i]);
19352    
19353                                    if ((i + 1) < orderByConditionFields.length) {
19354                                            if (orderByComparator.isAscending() ^ previous) {
19355                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
19356                                            }
19357                                            else {
19358                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
19359                                            }
19360                                    }
19361                                    else {
19362                                            if (orderByComparator.isAscending() ^ previous) {
19363                                                    query.append(WHERE_GREATER_THAN);
19364                                            }
19365                                            else {
19366                                                    query.append(WHERE_LESSER_THAN);
19367                                            }
19368                                    }
19369                            }
19370    
19371                            query.append(ORDER_BY_CLAUSE);
19372    
19373                            String[] orderByFields = orderByComparator.getOrderByFields();
19374    
19375                            for (int i = 0; i < orderByFields.length; i++) {
19376                                    query.append(_ORDER_BY_ENTITY_ALIAS);
19377                                    query.append(orderByFields[i]);
19378    
19379                                    if ((i + 1) < orderByFields.length) {
19380                                            if (orderByComparator.isAscending() ^ previous) {
19381                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
19382                                            }
19383                                            else {
19384                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
19385                                            }
19386                                    }
19387                                    else {
19388                                            if (orderByComparator.isAscending() ^ previous) {
19389                                                    query.append(ORDER_BY_ASC);
19390                                            }
19391                                            else {
19392                                                    query.append(ORDER_BY_DESC);
19393                                            }
19394                                    }
19395                            }
19396                    }
19397                    else {
19398                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19399                    }
19400    
19401                    String sql = query.toString();
19402    
19403                    Query q = session.createQuery(sql);
19404    
19405                    q.setFirstResult(0);
19406                    q.setMaxResults(2);
19407    
19408                    QueryPos qPos = QueryPos.getInstance(q);
19409    
19410                    qPos.add(groupId);
19411    
19412                    qPos.add(userId);
19413    
19414                    qPos.add(classNameId);
19415    
19416                    if (orderByComparator != null) {
19417                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
19418    
19419                            for (Object value : values) {
19420                                    qPos.add(value);
19421                            }
19422                    }
19423    
19424                    List<JournalArticle> list = q.list();
19425    
19426                    if (list.size() == 2) {
19427                            return list.get(1);
19428                    }
19429                    else {
19430                            return null;
19431                    }
19432            }
19433    
19434            /**
19435             * Returns all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
19436             *
19437             * @param groupId the group ID
19438             * @param userId the user ID
19439             * @param classNameId the class name ID
19440             * @return the matching journal articles that the user has permission to view
19441             * @throws SystemException if a system exception occurred
19442             */
19443            @Override
19444            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
19445                    long classNameId) throws SystemException {
19446                    return filterFindByG_U_C(groupId, userId, classNameId,
19447                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
19448            }
19449    
19450            /**
19451             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
19452             *
19453             * <p>
19454             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19455             * </p>
19456             *
19457             * @param groupId the group ID
19458             * @param userId the user ID
19459             * @param classNameId the class name ID
19460             * @param start the lower bound of the range of journal articles
19461             * @param end the upper bound of the range of journal articles (not inclusive)
19462             * @return the range of matching journal articles that the user has permission to view
19463             * @throws SystemException if a system exception occurred
19464             */
19465            @Override
19466            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
19467                    long classNameId, int start, int end) throws SystemException {
19468                    return filterFindByG_U_C(groupId, userId, classNameId, start, end, null);
19469            }
19470    
19471            /**
19472             * 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;.
19473             *
19474             * <p>
19475             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19476             * </p>
19477             *
19478             * @param groupId the group ID
19479             * @param userId the user ID
19480             * @param classNameId the class name ID
19481             * @param start the lower bound of the range of journal articles
19482             * @param end the upper bound of the range of journal articles (not inclusive)
19483             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19484             * @return the ordered range of matching journal articles that the user has permission to view
19485             * @throws SystemException if a system exception occurred
19486             */
19487            @Override
19488            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
19489                    long classNameId, int start, int end,
19490                    OrderByComparator orderByComparator) throws SystemException {
19491                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19492                            return findByG_U_C(groupId, userId, classNameId, start, end,
19493                                    orderByComparator);
19494                    }
19495    
19496                    StringBundler query = null;
19497    
19498                    if (orderByComparator != null) {
19499                            query = new StringBundler(5 +
19500                                            (orderByComparator.getOrderByFields().length * 3));
19501                    }
19502                    else {
19503                            query = new StringBundler(5);
19504                    }
19505    
19506                    if (getDB().isSupportsInlineDistinct()) {
19507                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
19508                    }
19509                    else {
19510                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
19511                    }
19512    
19513                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
19514    
19515                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
19516    
19517                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
19518    
19519                    if (!getDB().isSupportsInlineDistinct()) {
19520                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
19521                    }
19522    
19523                    if (orderByComparator != null) {
19524                            if (getDB().isSupportsInlineDistinct()) {
19525                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
19526                                            orderByComparator, true);
19527                            }
19528                            else {
19529                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
19530                                            orderByComparator, true);
19531                            }
19532                    }
19533                    else {
19534                            if (getDB().isSupportsInlineDistinct()) {
19535                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19536                            }
19537                            else {
19538                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
19539                            }
19540                    }
19541    
19542                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19543                                    JournalArticle.class.getName(),
19544                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19545    
19546                    Session session = null;
19547    
19548                    try {
19549                            session = openSession();
19550    
19551                            SQLQuery q = session.createSQLQuery(sql);
19552    
19553                            if (getDB().isSupportsInlineDistinct()) {
19554                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
19555                            }
19556                            else {
19557                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
19558                            }
19559    
19560                            QueryPos qPos = QueryPos.getInstance(q);
19561    
19562                            qPos.add(groupId);
19563    
19564                            qPos.add(userId);
19565    
19566                            qPos.add(classNameId);
19567    
19568                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
19569                                    end);
19570                    }
19571                    catch (Exception e) {
19572                            throw processException(e);
19573                    }
19574                    finally {
19575                            closeSession(session);
19576                    }
19577            }
19578    
19579            /**
19580             * 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;.
19581             *
19582             * @param id the primary key of the current journal article
19583             * @param groupId the group ID
19584             * @param userId the user ID
19585             * @param classNameId the class name ID
19586             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19587             * @return the previous, current, and next journal article
19588             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
19589             * @throws SystemException if a system exception occurred
19590             */
19591            @Override
19592            public JournalArticle[] filterFindByG_U_C_PrevAndNext(long id,
19593                    long groupId, long userId, long classNameId,
19594                    OrderByComparator orderByComparator)
19595                    throws NoSuchArticleException, SystemException {
19596                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19597                            return findByG_U_C_PrevAndNext(id, groupId, userId, classNameId,
19598                                    orderByComparator);
19599                    }
19600    
19601                    JournalArticle journalArticle = findByPrimaryKey(id);
19602    
19603                    Session session = null;
19604    
19605                    try {
19606                            session = openSession();
19607    
19608                            JournalArticle[] array = new JournalArticleImpl[3];
19609    
19610                            array[0] = filterGetByG_U_C_PrevAndNext(session, journalArticle,
19611                                            groupId, userId, classNameId, orderByComparator, true);
19612    
19613                            array[1] = journalArticle;
19614    
19615                            array[2] = filterGetByG_U_C_PrevAndNext(session, journalArticle,
19616                                            groupId, userId, classNameId, orderByComparator, false);
19617    
19618                            return array;
19619                    }
19620                    catch (Exception e) {
19621                            throw processException(e);
19622                    }
19623                    finally {
19624                            closeSession(session);
19625                    }
19626            }
19627    
19628            protected JournalArticle filterGetByG_U_C_PrevAndNext(Session session,
19629                    JournalArticle journalArticle, long groupId, long userId,
19630                    long classNameId, OrderByComparator orderByComparator, boolean previous) {
19631                    StringBundler query = null;
19632    
19633                    if (orderByComparator != null) {
19634                            query = new StringBundler(6 +
19635                                            (orderByComparator.getOrderByFields().length * 6));
19636                    }
19637                    else {
19638                            query = new StringBundler(3);
19639                    }
19640    
19641                    if (getDB().isSupportsInlineDistinct()) {
19642                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
19643                    }
19644                    else {
19645                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
19646                    }
19647    
19648                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
19649    
19650                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
19651    
19652                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
19653    
19654                    if (!getDB().isSupportsInlineDistinct()) {
19655                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
19656                    }
19657    
19658                    if (orderByComparator != null) {
19659                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
19660    
19661                            if (orderByConditionFields.length > 0) {
19662                                    query.append(WHERE_AND);
19663                            }
19664    
19665                            for (int i = 0; i < orderByConditionFields.length; i++) {
19666                                    if (getDB().isSupportsInlineDistinct()) {
19667                                            query.append(_ORDER_BY_ENTITY_ALIAS);
19668                                    }
19669                                    else {
19670                                            query.append(_ORDER_BY_ENTITY_TABLE);
19671                                    }
19672    
19673                                    query.append(orderByConditionFields[i]);
19674    
19675                                    if ((i + 1) < orderByConditionFields.length) {
19676                                            if (orderByComparator.isAscending() ^ previous) {
19677                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
19678                                            }
19679                                            else {
19680                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
19681                                            }
19682                                    }
19683                                    else {
19684                                            if (orderByComparator.isAscending() ^ previous) {
19685                                                    query.append(WHERE_GREATER_THAN);
19686                                            }
19687                                            else {
19688                                                    query.append(WHERE_LESSER_THAN);
19689                                            }
19690                                    }
19691                            }
19692    
19693                            query.append(ORDER_BY_CLAUSE);
19694    
19695                            String[] orderByFields = orderByComparator.getOrderByFields();
19696    
19697                            for (int i = 0; i < orderByFields.length; i++) {
19698                                    if (getDB().isSupportsInlineDistinct()) {
19699                                            query.append(_ORDER_BY_ENTITY_ALIAS);
19700                                    }
19701                                    else {
19702                                            query.append(_ORDER_BY_ENTITY_TABLE);
19703                                    }
19704    
19705                                    query.append(orderByFields[i]);
19706    
19707                                    if ((i + 1) < orderByFields.length) {
19708                                            if (orderByComparator.isAscending() ^ previous) {
19709                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
19710                                            }
19711                                            else {
19712                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
19713                                            }
19714                                    }
19715                                    else {
19716                                            if (orderByComparator.isAscending() ^ previous) {
19717                                                    query.append(ORDER_BY_ASC);
19718                                            }
19719                                            else {
19720                                                    query.append(ORDER_BY_DESC);
19721                                            }
19722                                    }
19723                            }
19724                    }
19725                    else {
19726                            if (getDB().isSupportsInlineDistinct()) {
19727                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19728                            }
19729                            else {
19730                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
19731                            }
19732                    }
19733    
19734                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19735                                    JournalArticle.class.getName(),
19736                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19737    
19738                    SQLQuery q = session.createSQLQuery(sql);
19739    
19740                    q.setFirstResult(0);
19741                    q.setMaxResults(2);
19742    
19743                    if (getDB().isSupportsInlineDistinct()) {
19744                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
19745                    }
19746                    else {
19747                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
19748                    }
19749    
19750                    QueryPos qPos = QueryPos.getInstance(q);
19751    
19752                    qPos.add(groupId);
19753    
19754                    qPos.add(userId);
19755    
19756                    qPos.add(classNameId);
19757    
19758                    if (orderByComparator != null) {
19759                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
19760    
19761                            for (Object value : values) {
19762                                    qPos.add(value);
19763                            }
19764                    }
19765    
19766                    List<JournalArticle> list = q.list();
19767    
19768                    if (list.size() == 2) {
19769                            return list.get(1);
19770                    }
19771                    else {
19772                            return null;
19773                    }
19774            }
19775    
19776            /**
19777             * Removes all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63; from the database.
19778             *
19779             * @param groupId the group ID
19780             * @param userId the user ID
19781             * @param classNameId the class name ID
19782             * @throws SystemException if a system exception occurred
19783             */
19784            @Override
19785            public void removeByG_U_C(long groupId, long userId, long classNameId)
19786                    throws SystemException {
19787                    for (JournalArticle journalArticle : findByG_U_C(groupId, userId,
19788                                    classNameId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
19789                            remove(journalArticle);
19790                    }
19791            }
19792    
19793            /**
19794             * Returns the number of journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
19795             *
19796             * @param groupId the group ID
19797             * @param userId the user ID
19798             * @param classNameId the class name ID
19799             * @return the number of matching journal articles
19800             * @throws SystemException if a system exception occurred
19801             */
19802            @Override
19803            public int countByG_U_C(long groupId, long userId, long classNameId)
19804                    throws SystemException {
19805                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_C;
19806    
19807                    Object[] finderArgs = new Object[] { groupId, userId, classNameId };
19808    
19809                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
19810                                    this);
19811    
19812                    if (count == null) {
19813                            StringBundler query = new StringBundler(4);
19814    
19815                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
19816    
19817                            query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
19818    
19819                            query.append(_FINDER_COLUMN_G_U_C_USERID_2);
19820    
19821                            query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
19822    
19823                            String sql = query.toString();
19824    
19825                            Session session = null;
19826    
19827                            try {
19828                                    session = openSession();
19829    
19830                                    Query q = session.createQuery(sql);
19831    
19832                                    QueryPos qPos = QueryPos.getInstance(q);
19833    
19834                                    qPos.add(groupId);
19835    
19836                                    qPos.add(userId);
19837    
19838                                    qPos.add(classNameId);
19839    
19840                                    count = (Long)q.uniqueResult();
19841    
19842                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
19843                            }
19844                            catch (Exception e) {
19845                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
19846    
19847                                    throw processException(e);
19848                            }
19849                            finally {
19850                                    closeSession(session);
19851                            }
19852                    }
19853    
19854                    return count.intValue();
19855            }
19856    
19857            /**
19858             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
19859             *
19860             * @param groupId the group ID
19861             * @param userId the user ID
19862             * @param classNameId the class name ID
19863             * @return the number of matching journal articles that the user has permission to view
19864             * @throws SystemException if a system exception occurred
19865             */
19866            @Override
19867            public int filterCountByG_U_C(long groupId, long userId, long classNameId)
19868                    throws SystemException {
19869                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19870                            return countByG_U_C(groupId, userId, classNameId);
19871                    }
19872    
19873                    StringBundler query = new StringBundler(4);
19874    
19875                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
19876    
19877                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
19878    
19879                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
19880    
19881                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
19882    
19883                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19884                                    JournalArticle.class.getName(),
19885                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19886    
19887                    Session session = null;
19888    
19889                    try {
19890                            session = openSession();
19891    
19892                            SQLQuery q = session.createSQLQuery(sql);
19893    
19894                            q.addScalar(COUNT_COLUMN_NAME,
19895                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
19896    
19897                            QueryPos qPos = QueryPos.getInstance(q);
19898    
19899                            qPos.add(groupId);
19900    
19901                            qPos.add(userId);
19902    
19903                            qPos.add(classNameId);
19904    
19905                            Long count = (Long)q.uniqueResult();
19906    
19907                            return count.intValue();
19908                    }
19909                    catch (Exception e) {
19910                            throw processException(e);
19911                    }
19912                    finally {
19913                            closeSession(session);
19914                    }
19915            }
19916    
19917            private static final String _FINDER_COLUMN_G_U_C_GROUPID_2 = "journalArticle.groupId = ? AND ";
19918            private static final String _FINDER_COLUMN_G_U_C_USERID_2 = "journalArticle.userId = ? AND ";
19919            private static final String _FINDER_COLUMN_G_U_C_CLASSNAMEID_2 = "journalArticle.classNameId = ?";
19920            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19921                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
19922                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
19923                            "findByG_F_ST",
19924                            new String[] {
19925                                    Long.class.getName(), Long.class.getName(),
19926                                    Integer.class.getName(),
19927                                    
19928                            Integer.class.getName(), Integer.class.getName(),
19929                                    OrderByComparator.class.getName()
19930                            });
19931            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST =
19932                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19933                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
19934                            JournalArticleImpl.class,
19935                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F_ST",
19936                            new String[] {
19937                                    Long.class.getName(), Long.class.getName(),
19938                                    Integer.class.getName()
19939                            },
19940                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
19941                            JournalArticleModelImpl.FOLDERID_COLUMN_BITMASK |
19942                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
19943                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
19944                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
19945            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19946                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
19947                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_ST",
19948                            new String[] {
19949                                    Long.class.getName(), Long.class.getName(),
19950                                    Integer.class.getName()
19951                            });
19952            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19953                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
19954                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F_ST",
19955                            new String[] {
19956                                    Long.class.getName(), Long.class.getName(),
19957                                    Integer.class.getName()
19958                            });
19959    
19960            /**
19961             * Returns all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
19962             *
19963             * @param groupId the group ID
19964             * @param folderId the folder ID
19965             * @param status the status
19966             * @return the matching journal articles
19967             * @throws SystemException if a system exception occurred
19968             */
19969            @Override
19970            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
19971                    int status) throws SystemException {
19972                    return findByG_F_ST(groupId, folderId, status, QueryUtil.ALL_POS,
19973                            QueryUtil.ALL_POS, null);
19974            }
19975    
19976            /**
19977             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
19978             *
19979             * <p>
19980             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19981             * </p>
19982             *
19983             * @param groupId the group ID
19984             * @param folderId the folder ID
19985             * @param status the status
19986             * @param start the lower bound of the range of journal articles
19987             * @param end the upper bound of the range of journal articles (not inclusive)
19988             * @return the range of matching journal articles
19989             * @throws SystemException if a system exception occurred
19990             */
19991            @Override
19992            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
19993                    int status, int start, int end) throws SystemException {
19994                    return findByG_F_ST(groupId, folderId, status, start, end, null);
19995            }
19996    
19997            /**
19998             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
19999             *
20000             * <p>
20001             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20002             * </p>
20003             *
20004             * @param groupId the group ID
20005             * @param folderId the folder ID
20006             * @param status the status
20007             * @param start the lower bound of the range of journal articles
20008             * @param end the upper bound of the range of journal articles (not inclusive)
20009             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
20010             * @return the ordered range of matching journal articles
20011             * @throws SystemException if a system exception occurred
20012             */
20013            @Override
20014            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
20015                    int status, int start, int end, OrderByComparator orderByComparator)
20016                    throws SystemException {
20017                    boolean pagination = true;
20018                    FinderPath finderPath = null;
20019                    Object[] finderArgs = null;
20020    
20021                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
20022                                    (orderByComparator == null)) {
20023                            pagination = false;
20024                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST;
20025                            finderArgs = new Object[] { groupId, folderId, status };
20026                    }
20027                    else {
20028                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST;
20029                            finderArgs = new Object[] {
20030                                            groupId, folderId, status,
20031                                            
20032                                            start, end, orderByComparator
20033                                    };
20034                    }
20035    
20036                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
20037                                    finderArgs, this);
20038    
20039                    if ((list != null) && !list.isEmpty()) {
20040                            for (JournalArticle journalArticle : list) {
20041                                    if ((groupId != journalArticle.getGroupId()) ||
20042                                                    (folderId != journalArticle.getFolderId()) ||
20043                                                    (status != journalArticle.getStatus())) {
20044                                            list = null;
20045    
20046                                            break;
20047                                    }
20048                            }
20049                    }
20050    
20051                    if (list == null) {
20052                            StringBundler query = null;
20053    
20054                            if (orderByComparator != null) {
20055                                    query = new StringBundler(5 +
20056                                                    (orderByComparator.getOrderByFields().length * 3));
20057                            }
20058                            else {
20059                                    query = new StringBundler(5);
20060                            }
20061    
20062                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
20063    
20064                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
20065    
20066                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
20067    
20068                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
20069    
20070                            if (orderByComparator != null) {
20071                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
20072                                            orderByComparator);
20073                            }
20074                            else
20075                             if (pagination) {
20076                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20077                            }
20078    
20079                            String sql = query.toString();
20080    
20081                            Session session = null;
20082    
20083                            try {
20084                                    session = openSession();
20085    
20086                                    Query q = session.createQuery(sql);
20087    
20088                                    QueryPos qPos = QueryPos.getInstance(q);
20089    
20090                                    qPos.add(groupId);
20091    
20092                                    qPos.add(folderId);
20093    
20094                                    qPos.add(status);
20095    
20096                                    if (!pagination) {
20097                                            list = (List<JournalArticle>)QueryUtil.list(q,
20098                                                            getDialect(), start, end, false);
20099    
20100                                            Collections.sort(list);
20101    
20102                                            list = new UnmodifiableList<JournalArticle>(list);
20103                                    }
20104                                    else {
20105                                            list = (List<JournalArticle>)QueryUtil.list(q,
20106                                                            getDialect(), start, end);
20107                                    }
20108    
20109                                    cacheResult(list);
20110    
20111                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
20112                            }
20113                            catch (Exception e) {
20114                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
20115    
20116                                    throw processException(e);
20117                            }
20118                            finally {
20119                                    closeSession(session);
20120                            }
20121                    }
20122    
20123                    return list;
20124            }
20125    
20126            /**
20127             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
20128             *
20129             * @param groupId the group ID
20130             * @param folderId the folder ID
20131             * @param status the status
20132             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20133             * @return the first matching journal article
20134             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
20135             * @throws SystemException if a system exception occurred
20136             */
20137            @Override
20138            public JournalArticle findByG_F_ST_First(long groupId, long folderId,
20139                    int status, OrderByComparator orderByComparator)
20140                    throws NoSuchArticleException, SystemException {
20141                    JournalArticle journalArticle = fetchByG_F_ST_First(groupId, folderId,
20142                                    status, orderByComparator);
20143    
20144                    if (journalArticle != null) {
20145                            return journalArticle;
20146                    }
20147    
20148                    StringBundler msg = new StringBundler(8);
20149    
20150                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
20151    
20152                    msg.append("groupId=");
20153                    msg.append(groupId);
20154    
20155                    msg.append(", folderId=");
20156                    msg.append(folderId);
20157    
20158                    msg.append(", status=");
20159                    msg.append(status);
20160    
20161                    msg.append(StringPool.CLOSE_CURLY_BRACE);
20162    
20163                    throw new NoSuchArticleException(msg.toString());
20164            }
20165    
20166            /**
20167             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
20168             *
20169             * @param groupId the group ID
20170             * @param folderId the folder ID
20171             * @param status the status
20172             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20173             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
20174             * @throws SystemException if a system exception occurred
20175             */
20176            @Override
20177            public JournalArticle fetchByG_F_ST_First(long groupId, long folderId,
20178                    int status, OrderByComparator orderByComparator)
20179                    throws SystemException {
20180                    List<JournalArticle> list = findByG_F_ST(groupId, folderId, status, 0,
20181                                    1, orderByComparator);
20182    
20183                    if (!list.isEmpty()) {
20184                            return list.get(0);
20185                    }
20186    
20187                    return null;
20188            }
20189    
20190            /**
20191             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
20192             *
20193             * @param groupId the group ID
20194             * @param folderId the folder ID
20195             * @param status the status
20196             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20197             * @return the last matching journal article
20198             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
20199             * @throws SystemException if a system exception occurred
20200             */
20201            @Override
20202            public JournalArticle findByG_F_ST_Last(long groupId, long folderId,
20203                    int status, OrderByComparator orderByComparator)
20204                    throws NoSuchArticleException, SystemException {
20205                    JournalArticle journalArticle = fetchByG_F_ST_Last(groupId, folderId,
20206                                    status, orderByComparator);
20207    
20208                    if (journalArticle != null) {
20209                            return journalArticle;
20210                    }
20211    
20212                    StringBundler msg = new StringBundler(8);
20213    
20214                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
20215    
20216                    msg.append("groupId=");
20217                    msg.append(groupId);
20218    
20219                    msg.append(", folderId=");
20220                    msg.append(folderId);
20221    
20222                    msg.append(", status=");
20223                    msg.append(status);
20224    
20225                    msg.append(StringPool.CLOSE_CURLY_BRACE);
20226    
20227                    throw new NoSuchArticleException(msg.toString());
20228            }
20229    
20230            /**
20231             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
20232             *
20233             * @param groupId the group ID
20234             * @param folderId the folder ID
20235             * @param status the status
20236             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20237             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
20238             * @throws SystemException if a system exception occurred
20239             */
20240            @Override
20241            public JournalArticle fetchByG_F_ST_Last(long groupId, long folderId,
20242                    int status, OrderByComparator orderByComparator)
20243                    throws SystemException {
20244                    int count = countByG_F_ST(groupId, folderId, status);
20245    
20246                    if (count == 0) {
20247                            return null;
20248                    }
20249    
20250                    List<JournalArticle> list = findByG_F_ST(groupId, folderId, status,
20251                                    count - 1, count, orderByComparator);
20252    
20253                    if (!list.isEmpty()) {
20254                            return list.get(0);
20255                    }
20256    
20257                    return null;
20258            }
20259    
20260            /**
20261             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
20262             *
20263             * @param id the primary key of the current journal article
20264             * @param groupId the group ID
20265             * @param folderId the folder ID
20266             * @param status the status
20267             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20268             * @return the previous, current, and next journal article
20269             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
20270             * @throws SystemException if a system exception occurred
20271             */
20272            @Override
20273            public JournalArticle[] findByG_F_ST_PrevAndNext(long id, long groupId,
20274                    long folderId, int status, OrderByComparator orderByComparator)
20275                    throws NoSuchArticleException, SystemException {
20276                    JournalArticle journalArticle = findByPrimaryKey(id);
20277    
20278                    Session session = null;
20279    
20280                    try {
20281                            session = openSession();
20282    
20283                            JournalArticle[] array = new JournalArticleImpl[3];
20284    
20285                            array[0] = getByG_F_ST_PrevAndNext(session, journalArticle,
20286                                            groupId, folderId, status, orderByComparator, true);
20287    
20288                            array[1] = journalArticle;
20289    
20290                            array[2] = getByG_F_ST_PrevAndNext(session, journalArticle,
20291                                            groupId, folderId, status, orderByComparator, false);
20292    
20293                            return array;
20294                    }
20295                    catch (Exception e) {
20296                            throw processException(e);
20297                    }
20298                    finally {
20299                            closeSession(session);
20300                    }
20301            }
20302    
20303            protected JournalArticle getByG_F_ST_PrevAndNext(Session session,
20304                    JournalArticle journalArticle, long groupId, long folderId, int status,
20305                    OrderByComparator orderByComparator, boolean previous) {
20306                    StringBundler query = null;
20307    
20308                    if (orderByComparator != null) {
20309                            query = new StringBundler(6 +
20310                                            (orderByComparator.getOrderByFields().length * 6));
20311                    }
20312                    else {
20313                            query = new StringBundler(3);
20314                    }
20315    
20316                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
20317    
20318                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
20319    
20320                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
20321    
20322                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
20323    
20324                    if (orderByComparator != null) {
20325                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
20326    
20327                            if (orderByConditionFields.length > 0) {
20328                                    query.append(WHERE_AND);
20329                            }
20330    
20331                            for (int i = 0; i < orderByConditionFields.length; i++) {
20332                                    query.append(_ORDER_BY_ENTITY_ALIAS);
20333                                    query.append(orderByConditionFields[i]);
20334    
20335                                    if ((i + 1) < orderByConditionFields.length) {
20336                                            if (orderByComparator.isAscending() ^ previous) {
20337                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
20338                                            }
20339                                            else {
20340                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
20341                                            }
20342                                    }
20343                                    else {
20344                                            if (orderByComparator.isAscending() ^ previous) {
20345                                                    query.append(WHERE_GREATER_THAN);
20346                                            }
20347                                            else {
20348                                                    query.append(WHERE_LESSER_THAN);
20349                                            }
20350                                    }
20351                            }
20352    
20353                            query.append(ORDER_BY_CLAUSE);
20354    
20355                            String[] orderByFields = orderByComparator.getOrderByFields();
20356    
20357                            for (int i = 0; i < orderByFields.length; i++) {
20358                                    query.append(_ORDER_BY_ENTITY_ALIAS);
20359                                    query.append(orderByFields[i]);
20360    
20361                                    if ((i + 1) < orderByFields.length) {
20362                                            if (orderByComparator.isAscending() ^ previous) {
20363                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
20364                                            }
20365                                            else {
20366                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
20367                                            }
20368                                    }
20369                                    else {
20370                                            if (orderByComparator.isAscending() ^ previous) {
20371                                                    query.append(ORDER_BY_ASC);
20372                                            }
20373                                            else {
20374                                                    query.append(ORDER_BY_DESC);
20375                                            }
20376                                    }
20377                            }
20378                    }
20379                    else {
20380                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20381                    }
20382    
20383                    String sql = query.toString();
20384    
20385                    Query q = session.createQuery(sql);
20386    
20387                    q.setFirstResult(0);
20388                    q.setMaxResults(2);
20389    
20390                    QueryPos qPos = QueryPos.getInstance(q);
20391    
20392                    qPos.add(groupId);
20393    
20394                    qPos.add(folderId);
20395    
20396                    qPos.add(status);
20397    
20398                    if (orderByComparator != null) {
20399                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
20400    
20401                            for (Object value : values) {
20402                                    qPos.add(value);
20403                            }
20404                    }
20405    
20406                    List<JournalArticle> list = q.list();
20407    
20408                    if (list.size() == 2) {
20409                            return list.get(1);
20410                    }
20411                    else {
20412                            return null;
20413                    }
20414            }
20415    
20416            /**
20417             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
20418             *
20419             * @param groupId the group ID
20420             * @param folderId the folder ID
20421             * @param status the status
20422             * @return the matching journal articles that the user has permission to view
20423             * @throws SystemException if a system exception occurred
20424             */
20425            @Override
20426            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
20427                    int status) throws SystemException {
20428                    return filterFindByG_F_ST(groupId, folderId, status, QueryUtil.ALL_POS,
20429                            QueryUtil.ALL_POS, null);
20430            }
20431    
20432            /**
20433             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
20434             *
20435             * <p>
20436             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20437             * </p>
20438             *
20439             * @param groupId the group ID
20440             * @param folderId the folder ID
20441             * @param status the status
20442             * @param start the lower bound of the range of journal articles
20443             * @param end the upper bound of the range of journal articles (not inclusive)
20444             * @return the range of matching journal articles that the user has permission to view
20445             * @throws SystemException if a system exception occurred
20446             */
20447            @Override
20448            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
20449                    int status, int start, int end) throws SystemException {
20450                    return filterFindByG_F_ST(groupId, folderId, status, start, end, null);
20451            }
20452    
20453            /**
20454             * 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;.
20455             *
20456             * <p>
20457             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20458             * </p>
20459             *
20460             * @param groupId the group ID
20461             * @param folderId the folder ID
20462             * @param status the status
20463             * @param start the lower bound of the range of journal articles
20464             * @param end the upper bound of the range of journal articles (not inclusive)
20465             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
20466             * @return the ordered range of matching journal articles that the user has permission to view
20467             * @throws SystemException if a system exception occurred
20468             */
20469            @Override
20470            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
20471                    int status, int start, int end, OrderByComparator orderByComparator)
20472                    throws SystemException {
20473                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20474                            return findByG_F_ST(groupId, folderId, status, start, end,
20475                                    orderByComparator);
20476                    }
20477    
20478                    StringBundler query = null;
20479    
20480                    if (orderByComparator != null) {
20481                            query = new StringBundler(5 +
20482                                            (orderByComparator.getOrderByFields().length * 3));
20483                    }
20484                    else {
20485                            query = new StringBundler(5);
20486                    }
20487    
20488                    if (getDB().isSupportsInlineDistinct()) {
20489                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
20490                    }
20491                    else {
20492                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
20493                    }
20494    
20495                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
20496    
20497                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
20498    
20499                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
20500    
20501                    if (!getDB().isSupportsInlineDistinct()) {
20502                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
20503                    }
20504    
20505                    if (orderByComparator != null) {
20506                            if (getDB().isSupportsInlineDistinct()) {
20507                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
20508                                            orderByComparator, true);
20509                            }
20510                            else {
20511                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
20512                                            orderByComparator, true);
20513                            }
20514                    }
20515                    else {
20516                            if (getDB().isSupportsInlineDistinct()) {
20517                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20518                            }
20519                            else {
20520                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
20521                            }
20522                    }
20523    
20524                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20525                                    JournalArticle.class.getName(),
20526                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20527    
20528                    Session session = null;
20529    
20530                    try {
20531                            session = openSession();
20532    
20533                            SQLQuery q = session.createSQLQuery(sql);
20534    
20535                            if (getDB().isSupportsInlineDistinct()) {
20536                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
20537                            }
20538                            else {
20539                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
20540                            }
20541    
20542                            QueryPos qPos = QueryPos.getInstance(q);
20543    
20544                            qPos.add(groupId);
20545    
20546                            qPos.add(folderId);
20547    
20548                            qPos.add(status);
20549    
20550                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
20551                                    end);
20552                    }
20553                    catch (Exception e) {
20554                            throw processException(e);
20555                    }
20556                    finally {
20557                            closeSession(session);
20558                    }
20559            }
20560    
20561            /**
20562             * 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;.
20563             *
20564             * @param id the primary key of the current journal article
20565             * @param groupId the group ID
20566             * @param folderId the folder ID
20567             * @param status the status
20568             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20569             * @return the previous, current, and next journal article
20570             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
20571             * @throws SystemException if a system exception occurred
20572             */
20573            @Override
20574            public JournalArticle[] filterFindByG_F_ST_PrevAndNext(long id,
20575                    long groupId, long folderId, int status,
20576                    OrderByComparator orderByComparator)
20577                    throws NoSuchArticleException, SystemException {
20578                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20579                            return findByG_F_ST_PrevAndNext(id, groupId, folderId, status,
20580                                    orderByComparator);
20581                    }
20582    
20583                    JournalArticle journalArticle = findByPrimaryKey(id);
20584    
20585                    Session session = null;
20586    
20587                    try {
20588                            session = openSession();
20589    
20590                            JournalArticle[] array = new JournalArticleImpl[3];
20591    
20592                            array[0] = filterGetByG_F_ST_PrevAndNext(session, journalArticle,
20593                                            groupId, folderId, status, orderByComparator, true);
20594    
20595                            array[1] = journalArticle;
20596    
20597                            array[2] = filterGetByG_F_ST_PrevAndNext(session, journalArticle,
20598                                            groupId, folderId, status, orderByComparator, false);
20599    
20600                            return array;
20601                    }
20602                    catch (Exception e) {
20603                            throw processException(e);
20604                    }
20605                    finally {
20606                            closeSession(session);
20607                    }
20608            }
20609    
20610            protected JournalArticle filterGetByG_F_ST_PrevAndNext(Session session,
20611                    JournalArticle journalArticle, long groupId, long folderId, int status,
20612                    OrderByComparator orderByComparator, boolean previous) {
20613                    StringBundler query = null;
20614    
20615                    if (orderByComparator != null) {
20616                            query = new StringBundler(6 +
20617                                            (orderByComparator.getOrderByFields().length * 6));
20618                    }
20619                    else {
20620                            query = new StringBundler(3);
20621                    }
20622    
20623                    if (getDB().isSupportsInlineDistinct()) {
20624                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
20625                    }
20626                    else {
20627                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
20628                    }
20629    
20630                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
20631    
20632                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
20633    
20634                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
20635    
20636                    if (!getDB().isSupportsInlineDistinct()) {
20637                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
20638                    }
20639    
20640                    if (orderByComparator != null) {
20641                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
20642    
20643                            if (orderByConditionFields.length > 0) {
20644                                    query.append(WHERE_AND);
20645                            }
20646    
20647                            for (int i = 0; i < orderByConditionFields.length; i++) {
20648                                    if (getDB().isSupportsInlineDistinct()) {
20649                                            query.append(_ORDER_BY_ENTITY_ALIAS);
20650                                    }
20651                                    else {
20652                                            query.append(_ORDER_BY_ENTITY_TABLE);
20653                                    }
20654    
20655                                    query.append(orderByConditionFields[i]);
20656    
20657                                    if ((i + 1) < orderByConditionFields.length) {
20658                                            if (orderByComparator.isAscending() ^ previous) {
20659                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
20660                                            }
20661                                            else {
20662                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
20663                                            }
20664                                    }
20665                                    else {
20666                                            if (orderByComparator.isAscending() ^ previous) {
20667                                                    query.append(WHERE_GREATER_THAN);
20668                                            }
20669                                            else {
20670                                                    query.append(WHERE_LESSER_THAN);
20671                                            }
20672                                    }
20673                            }
20674    
20675                            query.append(ORDER_BY_CLAUSE);
20676    
20677                            String[] orderByFields = orderByComparator.getOrderByFields();
20678    
20679                            for (int i = 0; i < orderByFields.length; i++) {
20680                                    if (getDB().isSupportsInlineDistinct()) {
20681                                            query.append(_ORDER_BY_ENTITY_ALIAS);
20682                                    }
20683                                    else {
20684                                            query.append(_ORDER_BY_ENTITY_TABLE);
20685                                    }
20686    
20687                                    query.append(orderByFields[i]);
20688    
20689                                    if ((i + 1) < orderByFields.length) {
20690                                            if (orderByComparator.isAscending() ^ previous) {
20691                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
20692                                            }
20693                                            else {
20694                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
20695                                            }
20696                                    }
20697                                    else {
20698                                            if (orderByComparator.isAscending() ^ previous) {
20699                                                    query.append(ORDER_BY_ASC);
20700                                            }
20701                                            else {
20702                                                    query.append(ORDER_BY_DESC);
20703                                            }
20704                                    }
20705                            }
20706                    }
20707                    else {
20708                            if (getDB().isSupportsInlineDistinct()) {
20709                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20710                            }
20711                            else {
20712                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
20713                            }
20714                    }
20715    
20716                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20717                                    JournalArticle.class.getName(),
20718                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20719    
20720                    SQLQuery q = session.createSQLQuery(sql);
20721    
20722                    q.setFirstResult(0);
20723                    q.setMaxResults(2);
20724    
20725                    if (getDB().isSupportsInlineDistinct()) {
20726                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
20727                    }
20728                    else {
20729                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
20730                    }
20731    
20732                    QueryPos qPos = QueryPos.getInstance(q);
20733    
20734                    qPos.add(groupId);
20735    
20736                    qPos.add(folderId);
20737    
20738                    qPos.add(status);
20739    
20740                    if (orderByComparator != null) {
20741                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
20742    
20743                            for (Object value : values) {
20744                                    qPos.add(value);
20745                            }
20746                    }
20747    
20748                    List<JournalArticle> list = q.list();
20749    
20750                    if (list.size() == 2) {
20751                            return list.get(1);
20752                    }
20753                    else {
20754                            return null;
20755                    }
20756            }
20757    
20758            /**
20759             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = any &#63;.
20760             *
20761             * @param groupId the group ID
20762             * @param folderId the folder ID
20763             * @param statuses the statuses
20764             * @return the matching journal articles that the user has permission to view
20765             * @throws SystemException if a system exception occurred
20766             */
20767            @Override
20768            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
20769                    int[] statuses) throws SystemException {
20770                    return filterFindByG_F_ST(groupId, folderId, statuses,
20771                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
20772            }
20773    
20774            /**
20775             * 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;.
20776             *
20777             * <p>
20778             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20779             * </p>
20780             *
20781             * @param groupId the group ID
20782             * @param folderId the folder ID
20783             * @param statuses the statuses
20784             * @param start the lower bound of the range of journal articles
20785             * @param end the upper bound of the range of journal articles (not inclusive)
20786             * @return the range of matching journal articles that the user has permission to view
20787             * @throws SystemException if a system exception occurred
20788             */
20789            @Override
20790            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
20791                    int[] statuses, int start, int end) throws SystemException {
20792                    return filterFindByG_F_ST(groupId, folderId, statuses, start, end, null);
20793            }
20794    
20795            /**
20796             * 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;.
20797             *
20798             * <p>
20799             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20800             * </p>
20801             *
20802             * @param groupId the group ID
20803             * @param folderId the folder ID
20804             * @param statuses the statuses
20805             * @param start the lower bound of the range of journal articles
20806             * @param end the upper bound of the range of journal articles (not inclusive)
20807             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
20808             * @return the ordered range of matching journal articles that the user has permission to view
20809             * @throws SystemException if a system exception occurred
20810             */
20811            @Override
20812            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
20813                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
20814                    throws SystemException {
20815                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20816                            return findByG_F_ST(groupId, folderId, statuses, start, end,
20817                                    orderByComparator);
20818                    }
20819    
20820                    StringBundler query = new StringBundler();
20821    
20822                    if (getDB().isSupportsInlineDistinct()) {
20823                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
20824                    }
20825                    else {
20826                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
20827                    }
20828    
20829                    boolean conjunctionable = false;
20830    
20831                    if (conjunctionable) {
20832                            query.append(WHERE_AND);
20833                    }
20834    
20835                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
20836    
20837                    conjunctionable = true;
20838    
20839                    if (conjunctionable) {
20840                            query.append(WHERE_AND);
20841                    }
20842    
20843                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
20844    
20845                    conjunctionable = true;
20846    
20847                    if ((statuses == null) || (statuses.length > 0)) {
20848                            if (conjunctionable) {
20849                                    query.append(WHERE_AND);
20850                            }
20851    
20852                            query.append(StringPool.OPEN_PARENTHESIS);
20853    
20854                            for (int i = 0; i < statuses.length; i++) {
20855                                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
20856    
20857                                    if ((i + 1) < statuses.length) {
20858                                            query.append(WHERE_OR);
20859                                    }
20860                            }
20861    
20862                            query.append(StringPool.CLOSE_PARENTHESIS);
20863    
20864                            conjunctionable = true;
20865                    }
20866    
20867                    if (!getDB().isSupportsInlineDistinct()) {
20868                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
20869                    }
20870    
20871                    if (orderByComparator != null) {
20872                            if (getDB().isSupportsInlineDistinct()) {
20873                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
20874                                            orderByComparator, true);
20875                            }
20876                            else {
20877                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
20878                                            orderByComparator, true);
20879                            }
20880                    }
20881                    else {
20882                            if (getDB().isSupportsInlineDistinct()) {
20883                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20884                            }
20885                            else {
20886                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
20887                            }
20888                    }
20889    
20890                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20891                                    JournalArticle.class.getName(),
20892                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20893    
20894                    Session session = null;
20895    
20896                    try {
20897                            session = openSession();
20898    
20899                            SQLQuery q = session.createSQLQuery(sql);
20900    
20901                            if (getDB().isSupportsInlineDistinct()) {
20902                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
20903                            }
20904                            else {
20905                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
20906                            }
20907    
20908                            QueryPos qPos = QueryPos.getInstance(q);
20909    
20910                            qPos.add(groupId);
20911    
20912                            qPos.add(folderId);
20913    
20914                            if (statuses != null) {
20915                                    qPos.add(statuses);
20916                            }
20917    
20918                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
20919                                    end);
20920                    }
20921                    catch (Exception e) {
20922                            throw processException(e);
20923                    }
20924                    finally {
20925                            closeSession(session);
20926                    }
20927            }
20928    
20929            /**
20930             * Returns all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
20931             *
20932             * <p>
20933             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20934             * </p>
20935             *
20936             * @param groupId the group ID
20937             * @param folderId the folder ID
20938             * @param statuses the statuses
20939             * @return the matching journal articles
20940             * @throws SystemException if a system exception occurred
20941             */
20942            @Override
20943            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
20944                    int[] statuses) throws SystemException {
20945                    return findByG_F_ST(groupId, folderId, statuses, QueryUtil.ALL_POS,
20946                            QueryUtil.ALL_POS, null);
20947            }
20948    
20949            /**
20950             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
20951             *
20952             * <p>
20953             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20954             * </p>
20955             *
20956             * @param groupId the group ID
20957             * @param folderId the folder ID
20958             * @param statuses the statuses
20959             * @param start the lower bound of the range of journal articles
20960             * @param end the upper bound of the range of journal articles (not inclusive)
20961             * @return the range of matching journal articles
20962             * @throws SystemException if a system exception occurred
20963             */
20964            @Override
20965            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
20966                    int[] statuses, int start, int end) throws SystemException {
20967                    return findByG_F_ST(groupId, folderId, statuses, start, end, null);
20968            }
20969    
20970            /**
20971             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
20972             *
20973             * <p>
20974             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20975             * </p>
20976             *
20977             * @param groupId the group ID
20978             * @param folderId the folder ID
20979             * @param statuses the statuses
20980             * @param start the lower bound of the range of journal articles
20981             * @param end the upper bound of the range of journal articles (not inclusive)
20982             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
20983             * @return the ordered range of matching journal articles
20984             * @throws SystemException if a system exception occurred
20985             */
20986            @Override
20987            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
20988                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
20989                    throws SystemException {
20990                    if ((statuses != null) && (statuses.length == 1)) {
20991                            return findByG_F_ST(groupId, folderId, statuses[0], start, end,
20992                                    orderByComparator);
20993                    }
20994    
20995                    boolean pagination = true;
20996                    Object[] finderArgs = null;
20997    
20998                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
20999                                    (orderByComparator == null)) {
21000                            pagination = false;
21001                            finderArgs = new Object[] {
21002                                            groupId, folderId, StringUtil.merge(statuses)
21003                                    };
21004                    }
21005                    else {
21006                            finderArgs = new Object[] {
21007                                            groupId, folderId, StringUtil.merge(statuses),
21008                                            
21009                                            start, end, orderByComparator
21010                                    };
21011                    }
21012    
21013                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
21014                                    finderArgs, this);
21015    
21016                    if ((list != null) && !list.isEmpty()) {
21017                            for (JournalArticle journalArticle : list) {
21018                                    if ((groupId != journalArticle.getGroupId()) ||
21019                                                    (folderId != journalArticle.getFolderId()) ||
21020                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
21021                                            list = null;
21022    
21023                                            break;
21024                                    }
21025                            }
21026                    }
21027    
21028                    if (list == null) {
21029                            StringBundler query = new StringBundler();
21030    
21031                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
21032    
21033                            boolean conjunctionable = false;
21034    
21035                            if (conjunctionable) {
21036                                    query.append(WHERE_AND);
21037                            }
21038    
21039                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
21040    
21041                            conjunctionable = true;
21042    
21043                            if (conjunctionable) {
21044                                    query.append(WHERE_AND);
21045                            }
21046    
21047                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
21048    
21049                            conjunctionable = true;
21050    
21051                            if ((statuses == null) || (statuses.length > 0)) {
21052                                    if (conjunctionable) {
21053                                            query.append(WHERE_AND);
21054                                    }
21055    
21056                                    query.append(StringPool.OPEN_PARENTHESIS);
21057    
21058                                    for (int i = 0; i < statuses.length; i++) {
21059                                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
21060    
21061                                            if ((i + 1) < statuses.length) {
21062                                                    query.append(WHERE_OR);
21063                                            }
21064                                    }
21065    
21066                                    query.append(StringPool.CLOSE_PARENTHESIS);
21067    
21068                                    conjunctionable = true;
21069                            }
21070    
21071                            if (orderByComparator != null) {
21072                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
21073                                            orderByComparator);
21074                            }
21075                            else
21076                             if (pagination) {
21077                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21078                            }
21079    
21080                            String sql = query.toString();
21081    
21082                            Session session = null;
21083    
21084                            try {
21085                                    session = openSession();
21086    
21087                                    Query q = session.createQuery(sql);
21088    
21089                                    QueryPos qPos = QueryPos.getInstance(q);
21090    
21091                                    qPos.add(groupId);
21092    
21093                                    qPos.add(folderId);
21094    
21095                                    if (statuses != null) {
21096                                            qPos.add(statuses);
21097                                    }
21098    
21099                                    if (!pagination) {
21100                                            list = (List<JournalArticle>)QueryUtil.list(q,
21101                                                            getDialect(), start, end, false);
21102    
21103                                            Collections.sort(list);
21104    
21105                                            list = new UnmodifiableList<JournalArticle>(list);
21106                                    }
21107                                    else {
21108                                            list = (List<JournalArticle>)QueryUtil.list(q,
21109                                                            getDialect(), start, end);
21110                                    }
21111    
21112                                    cacheResult(list);
21113    
21114                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
21115                                            finderArgs, list);
21116                            }
21117                            catch (Exception e) {
21118                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
21119                                            finderArgs);
21120    
21121                                    throw processException(e);
21122                            }
21123                            finally {
21124                                    closeSession(session);
21125                            }
21126                    }
21127    
21128                    return list;
21129            }
21130    
21131            /**
21132             * Removes all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63; from the database.
21133             *
21134             * @param groupId the group ID
21135             * @param folderId the folder ID
21136             * @param status the status
21137             * @throws SystemException if a system exception occurred
21138             */
21139            @Override
21140            public void removeByG_F_ST(long groupId, long folderId, int status)
21141                    throws SystemException {
21142                    for (JournalArticle journalArticle : findByG_F_ST(groupId, folderId,
21143                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
21144                            remove(journalArticle);
21145                    }
21146            }
21147    
21148            /**
21149             * Returns the number of journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
21150             *
21151             * @param groupId the group ID
21152             * @param folderId the folder ID
21153             * @param status the status
21154             * @return the number of matching journal articles
21155             * @throws SystemException if a system exception occurred
21156             */
21157            @Override
21158            public int countByG_F_ST(long groupId, long folderId, int status)
21159                    throws SystemException {
21160                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F_ST;
21161    
21162                    Object[] finderArgs = new Object[] { groupId, folderId, status };
21163    
21164                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
21165                                    this);
21166    
21167                    if (count == null) {
21168                            StringBundler query = new StringBundler(4);
21169    
21170                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
21171    
21172                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
21173    
21174                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
21175    
21176                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
21177    
21178                            String sql = query.toString();
21179    
21180                            Session session = null;
21181    
21182                            try {
21183                                    session = openSession();
21184    
21185                                    Query q = session.createQuery(sql);
21186    
21187                                    QueryPos qPos = QueryPos.getInstance(q);
21188    
21189                                    qPos.add(groupId);
21190    
21191                                    qPos.add(folderId);
21192    
21193                                    qPos.add(status);
21194    
21195                                    count = (Long)q.uniqueResult();
21196    
21197                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
21198                            }
21199                            catch (Exception e) {
21200                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
21201    
21202                                    throw processException(e);
21203                            }
21204                            finally {
21205                                    closeSession(session);
21206                            }
21207                    }
21208    
21209                    return count.intValue();
21210            }
21211    
21212            /**
21213             * Returns the number of journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
21214             *
21215             * @param groupId the group ID
21216             * @param folderId the folder ID
21217             * @param statuses the statuses
21218             * @return the number of matching journal articles
21219             * @throws SystemException if a system exception occurred
21220             */
21221            @Override
21222            public int countByG_F_ST(long groupId, long folderId, int[] statuses)
21223                    throws SystemException {
21224                    Object[] finderArgs = new Object[] {
21225                                    groupId, folderId, StringUtil.merge(statuses)
21226                            };
21227    
21228                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
21229                                    finderArgs, this);
21230    
21231                    if (count == null) {
21232                            StringBundler query = new StringBundler();
21233    
21234                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
21235    
21236                            boolean conjunctionable = false;
21237    
21238                            if (conjunctionable) {
21239                                    query.append(WHERE_AND);
21240                            }
21241    
21242                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
21243    
21244                            conjunctionable = true;
21245    
21246                            if (conjunctionable) {
21247                                    query.append(WHERE_AND);
21248                            }
21249    
21250                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
21251    
21252                            conjunctionable = true;
21253    
21254                            if ((statuses == null) || (statuses.length > 0)) {
21255                                    if (conjunctionable) {
21256                                            query.append(WHERE_AND);
21257                                    }
21258    
21259                                    query.append(StringPool.OPEN_PARENTHESIS);
21260    
21261                                    for (int i = 0; i < statuses.length; i++) {
21262                                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
21263    
21264                                            if ((i + 1) < statuses.length) {
21265                                                    query.append(WHERE_OR);
21266                                            }
21267                                    }
21268    
21269                                    query.append(StringPool.CLOSE_PARENTHESIS);
21270    
21271                                    conjunctionable = true;
21272                            }
21273    
21274                            String sql = query.toString();
21275    
21276                            Session session = null;
21277    
21278                            try {
21279                                    session = openSession();
21280    
21281                                    Query q = session.createQuery(sql);
21282    
21283                                    QueryPos qPos = QueryPos.getInstance(q);
21284    
21285                                    qPos.add(groupId);
21286    
21287                                    qPos.add(folderId);
21288    
21289                                    if (statuses != null) {
21290                                            qPos.add(statuses);
21291                                    }
21292    
21293                                    count = (Long)q.uniqueResult();
21294    
21295                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
21296                                            finderArgs, count);
21297                            }
21298                            catch (Exception e) {
21299                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
21300                                            finderArgs);
21301    
21302                                    throw processException(e);
21303                            }
21304                            finally {
21305                                    closeSession(session);
21306                            }
21307                    }
21308    
21309                    return count.intValue();
21310            }
21311    
21312            /**
21313             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
21314             *
21315             * @param groupId the group ID
21316             * @param folderId the folder ID
21317             * @param status the status
21318             * @return the number of matching journal articles that the user has permission to view
21319             * @throws SystemException if a system exception occurred
21320             */
21321            @Override
21322            public int filterCountByG_F_ST(long groupId, long folderId, int status)
21323                    throws SystemException {
21324                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21325                            return countByG_F_ST(groupId, folderId, status);
21326                    }
21327    
21328                    StringBundler query = new StringBundler(4);
21329    
21330                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
21331    
21332                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
21333    
21334                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
21335    
21336                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
21337    
21338                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21339                                    JournalArticle.class.getName(),
21340                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21341    
21342                    Session session = null;
21343    
21344                    try {
21345                            session = openSession();
21346    
21347                            SQLQuery q = session.createSQLQuery(sql);
21348    
21349                            q.addScalar(COUNT_COLUMN_NAME,
21350                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
21351    
21352                            QueryPos qPos = QueryPos.getInstance(q);
21353    
21354                            qPos.add(groupId);
21355    
21356                            qPos.add(folderId);
21357    
21358                            qPos.add(status);
21359    
21360                            Long count = (Long)q.uniqueResult();
21361    
21362                            return count.intValue();
21363                    }
21364                    catch (Exception e) {
21365                            throw processException(e);
21366                    }
21367                    finally {
21368                            closeSession(session);
21369                    }
21370            }
21371    
21372            /**
21373             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = any &#63;.
21374             *
21375             * @param groupId the group ID
21376             * @param folderId the folder ID
21377             * @param statuses the statuses
21378             * @return the number of matching journal articles that the user has permission to view
21379             * @throws SystemException if a system exception occurred
21380             */
21381            @Override
21382            public int filterCountByG_F_ST(long groupId, long folderId, int[] statuses)
21383                    throws SystemException {
21384                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21385                            return countByG_F_ST(groupId, folderId, statuses);
21386                    }
21387    
21388                    StringBundler query = new StringBundler();
21389    
21390                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
21391    
21392                    boolean conjunctionable = false;
21393    
21394                    if (conjunctionable) {
21395                            query.append(WHERE_AND);
21396                    }
21397    
21398                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
21399    
21400                    conjunctionable = true;
21401    
21402                    if (conjunctionable) {
21403                            query.append(WHERE_AND);
21404                    }
21405    
21406                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
21407    
21408                    conjunctionable = true;
21409    
21410                    if ((statuses == null) || (statuses.length > 0)) {
21411                            if (conjunctionable) {
21412                                    query.append(WHERE_AND);
21413                            }
21414    
21415                            query.append(StringPool.OPEN_PARENTHESIS);
21416    
21417                            for (int i = 0; i < statuses.length; i++) {
21418                                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
21419    
21420                                    if ((i + 1) < statuses.length) {
21421                                            query.append(WHERE_OR);
21422                                    }
21423                            }
21424    
21425                            query.append(StringPool.CLOSE_PARENTHESIS);
21426    
21427                            conjunctionable = true;
21428                    }
21429    
21430                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21431                                    JournalArticle.class.getName(),
21432                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21433    
21434                    Session session = null;
21435    
21436                    try {
21437                            session = openSession();
21438    
21439                            SQLQuery q = session.createSQLQuery(sql);
21440    
21441                            q.addScalar(COUNT_COLUMN_NAME,
21442                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
21443    
21444                            QueryPos qPos = QueryPos.getInstance(q);
21445    
21446                            qPos.add(groupId);
21447    
21448                            qPos.add(folderId);
21449    
21450                            if (statuses != null) {
21451                                    qPos.add(statuses);
21452                            }
21453    
21454                            Long count = (Long)q.uniqueResult();
21455    
21456                            return count.intValue();
21457                    }
21458                    catch (Exception e) {
21459                            throw processException(e);
21460                    }
21461                    finally {
21462                            closeSession(session);
21463                    }
21464            }
21465    
21466            private static final String _FINDER_COLUMN_G_F_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
21467            private static final String _FINDER_COLUMN_G_F_ST_GROUPID_5 = "(" +
21468                    removeConjunction(_FINDER_COLUMN_G_F_ST_GROUPID_2) + ")";
21469            private static final String _FINDER_COLUMN_G_F_ST_FOLDERID_2 = "journalArticle.folderId = ? AND ";
21470            private static final String _FINDER_COLUMN_G_F_ST_FOLDERID_5 = "(" +
21471                    removeConjunction(_FINDER_COLUMN_G_F_ST_FOLDERID_2) + ")";
21472            private static final String _FINDER_COLUMN_G_F_ST_STATUS_2 = "journalArticle.status = ?";
21473            private static final String _FINDER_COLUMN_G_F_ST_STATUS_5 = "(" +
21474                    removeConjunction(_FINDER_COLUMN_G_F_ST_STATUS_2) + ")";
21475            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
21476                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
21477                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
21478                            "findByG_C_C",
21479                            new String[] {
21480                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
21481                                    
21482                            Integer.class.getName(), Integer.class.getName(),
21483                                    OrderByComparator.class.getName()
21484                            });
21485            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
21486                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
21487                            JournalArticleImpl.class,
21488                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_C",
21489                            new String[] {
21490                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
21491                            },
21492                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
21493                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
21494                            JournalArticleModelImpl.CLASSPK_COLUMN_BITMASK |
21495                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
21496                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
21497            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
21498                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
21499                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_C",
21500                            new String[] {
21501                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
21502                            });
21503    
21504            /**
21505             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21506             *
21507             * @param groupId the group ID
21508             * @param classNameId the class name ID
21509             * @param classPK the class p k
21510             * @return the matching journal articles
21511             * @throws SystemException if a system exception occurred
21512             */
21513            @Override
21514            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
21515                    long classPK) throws SystemException {
21516                    return findByG_C_C(groupId, classNameId, classPK, QueryUtil.ALL_POS,
21517                            QueryUtil.ALL_POS, null);
21518            }
21519    
21520            /**
21521             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21522             *
21523             * <p>
21524             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
21525             * </p>
21526             *
21527             * @param groupId the group ID
21528             * @param classNameId the class name ID
21529             * @param classPK the class p k
21530             * @param start the lower bound of the range of journal articles
21531             * @param end the upper bound of the range of journal articles (not inclusive)
21532             * @return the range of matching journal articles
21533             * @throws SystemException if a system exception occurred
21534             */
21535            @Override
21536            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
21537                    long classPK, int start, int end) throws SystemException {
21538                    return findByG_C_C(groupId, classNameId, classPK, start, end, null);
21539            }
21540    
21541            /**
21542             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21543             *
21544             * <p>
21545             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
21546             * </p>
21547             *
21548             * @param groupId the group ID
21549             * @param classNameId the class name ID
21550             * @param classPK the class p k
21551             * @param start the lower bound of the range of journal articles
21552             * @param end the upper bound of the range of journal articles (not inclusive)
21553             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
21554             * @return the ordered range of matching journal articles
21555             * @throws SystemException if a system exception occurred
21556             */
21557            @Override
21558            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
21559                    long classPK, int start, int end, OrderByComparator orderByComparator)
21560                    throws SystemException {
21561                    boolean pagination = true;
21562                    FinderPath finderPath = null;
21563                    Object[] finderArgs = null;
21564    
21565                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
21566                                    (orderByComparator == null)) {
21567                            pagination = false;
21568                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C;
21569                            finderArgs = new Object[] { groupId, classNameId, classPK };
21570                    }
21571                    else {
21572                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C;
21573                            finderArgs = new Object[] {
21574                                            groupId, classNameId, classPK,
21575                                            
21576                                            start, end, orderByComparator
21577                                    };
21578                    }
21579    
21580                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
21581                                    finderArgs, this);
21582    
21583                    if ((list != null) && !list.isEmpty()) {
21584                            for (JournalArticle journalArticle : list) {
21585                                    if ((groupId != journalArticle.getGroupId()) ||
21586                                                    (classNameId != journalArticle.getClassNameId()) ||
21587                                                    (classPK != journalArticle.getClassPK())) {
21588                                            list = null;
21589    
21590                                            break;
21591                                    }
21592                            }
21593                    }
21594    
21595                    if (list == null) {
21596                            StringBundler query = null;
21597    
21598                            if (orderByComparator != null) {
21599                                    query = new StringBundler(5 +
21600                                                    (orderByComparator.getOrderByFields().length * 3));
21601                            }
21602                            else {
21603                                    query = new StringBundler(5);
21604                            }
21605    
21606                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
21607    
21608                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
21609    
21610                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
21611    
21612                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
21613    
21614                            if (orderByComparator != null) {
21615                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
21616                                            orderByComparator);
21617                            }
21618                            else
21619                             if (pagination) {
21620                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21621                            }
21622    
21623                            String sql = query.toString();
21624    
21625                            Session session = null;
21626    
21627                            try {
21628                                    session = openSession();
21629    
21630                                    Query q = session.createQuery(sql);
21631    
21632                                    QueryPos qPos = QueryPos.getInstance(q);
21633    
21634                                    qPos.add(groupId);
21635    
21636                                    qPos.add(classNameId);
21637    
21638                                    qPos.add(classPK);
21639    
21640                                    if (!pagination) {
21641                                            list = (List<JournalArticle>)QueryUtil.list(q,
21642                                                            getDialect(), start, end, false);
21643    
21644                                            Collections.sort(list);
21645    
21646                                            list = new UnmodifiableList<JournalArticle>(list);
21647                                    }
21648                                    else {
21649                                            list = (List<JournalArticle>)QueryUtil.list(q,
21650                                                            getDialect(), start, end);
21651                                    }
21652    
21653                                    cacheResult(list);
21654    
21655                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
21656                            }
21657                            catch (Exception e) {
21658                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
21659    
21660                                    throw processException(e);
21661                            }
21662                            finally {
21663                                    closeSession(session);
21664                            }
21665                    }
21666    
21667                    return list;
21668            }
21669    
21670            /**
21671             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21672             *
21673             * @param groupId the group ID
21674             * @param classNameId the class name ID
21675             * @param classPK the class p k
21676             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21677             * @return the first matching journal article
21678             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
21679             * @throws SystemException if a system exception occurred
21680             */
21681            @Override
21682            public JournalArticle findByG_C_C_First(long groupId, long classNameId,
21683                    long classPK, OrderByComparator orderByComparator)
21684                    throws NoSuchArticleException, SystemException {
21685                    JournalArticle journalArticle = fetchByG_C_C_First(groupId,
21686                                    classNameId, classPK, orderByComparator);
21687    
21688                    if (journalArticle != null) {
21689                            return journalArticle;
21690                    }
21691    
21692                    StringBundler msg = new StringBundler(8);
21693    
21694                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
21695    
21696                    msg.append("groupId=");
21697                    msg.append(groupId);
21698    
21699                    msg.append(", classNameId=");
21700                    msg.append(classNameId);
21701    
21702                    msg.append(", classPK=");
21703                    msg.append(classPK);
21704    
21705                    msg.append(StringPool.CLOSE_CURLY_BRACE);
21706    
21707                    throw new NoSuchArticleException(msg.toString());
21708            }
21709    
21710            /**
21711             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21712             *
21713             * @param groupId the group ID
21714             * @param classNameId the class name ID
21715             * @param classPK the class p k
21716             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21717             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
21718             * @throws SystemException if a system exception occurred
21719             */
21720            @Override
21721            public JournalArticle fetchByG_C_C_First(long groupId, long classNameId,
21722                    long classPK, OrderByComparator orderByComparator)
21723                    throws SystemException {
21724                    List<JournalArticle> list = findByG_C_C(groupId, classNameId, classPK,
21725                                    0, 1, orderByComparator);
21726    
21727                    if (!list.isEmpty()) {
21728                            return list.get(0);
21729                    }
21730    
21731                    return null;
21732            }
21733    
21734            /**
21735             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21736             *
21737             * @param groupId the group ID
21738             * @param classNameId the class name ID
21739             * @param classPK the class p k
21740             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21741             * @return the last matching journal article
21742             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
21743             * @throws SystemException if a system exception occurred
21744             */
21745            @Override
21746            public JournalArticle findByG_C_C_Last(long groupId, long classNameId,
21747                    long classPK, OrderByComparator orderByComparator)
21748                    throws NoSuchArticleException, SystemException {
21749                    JournalArticle journalArticle = fetchByG_C_C_Last(groupId, classNameId,
21750                                    classPK, orderByComparator);
21751    
21752                    if (journalArticle != null) {
21753                            return journalArticle;
21754                    }
21755    
21756                    StringBundler msg = new StringBundler(8);
21757    
21758                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
21759    
21760                    msg.append("groupId=");
21761                    msg.append(groupId);
21762    
21763                    msg.append(", classNameId=");
21764                    msg.append(classNameId);
21765    
21766                    msg.append(", classPK=");
21767                    msg.append(classPK);
21768    
21769                    msg.append(StringPool.CLOSE_CURLY_BRACE);
21770    
21771                    throw new NoSuchArticleException(msg.toString());
21772            }
21773    
21774            /**
21775             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21776             *
21777             * @param groupId the group ID
21778             * @param classNameId the class name ID
21779             * @param classPK the class p k
21780             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21781             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
21782             * @throws SystemException if a system exception occurred
21783             */
21784            @Override
21785            public JournalArticle fetchByG_C_C_Last(long groupId, long classNameId,
21786                    long classPK, OrderByComparator orderByComparator)
21787                    throws SystemException {
21788                    int count = countByG_C_C(groupId, classNameId, classPK);
21789    
21790                    if (count == 0) {
21791                            return null;
21792                    }
21793    
21794                    List<JournalArticle> list = findByG_C_C(groupId, classNameId, classPK,
21795                                    count - 1, count, orderByComparator);
21796    
21797                    if (!list.isEmpty()) {
21798                            return list.get(0);
21799                    }
21800    
21801                    return null;
21802            }
21803    
21804            /**
21805             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21806             *
21807             * @param id the primary key of the current journal article
21808             * @param groupId the group ID
21809             * @param classNameId the class name ID
21810             * @param classPK the class p k
21811             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21812             * @return the previous, current, and next journal article
21813             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
21814             * @throws SystemException if a system exception occurred
21815             */
21816            @Override
21817            public JournalArticle[] findByG_C_C_PrevAndNext(long id, long groupId,
21818                    long classNameId, long classPK, OrderByComparator orderByComparator)
21819                    throws NoSuchArticleException, SystemException {
21820                    JournalArticle journalArticle = findByPrimaryKey(id);
21821    
21822                    Session session = null;
21823    
21824                    try {
21825                            session = openSession();
21826    
21827                            JournalArticle[] array = new JournalArticleImpl[3];
21828    
21829                            array[0] = getByG_C_C_PrevAndNext(session, journalArticle, groupId,
21830                                            classNameId, classPK, orderByComparator, true);
21831    
21832                            array[1] = journalArticle;
21833    
21834                            array[2] = getByG_C_C_PrevAndNext(session, journalArticle, groupId,
21835                                            classNameId, classPK, orderByComparator, false);
21836    
21837                            return array;
21838                    }
21839                    catch (Exception e) {
21840                            throw processException(e);
21841                    }
21842                    finally {
21843                            closeSession(session);
21844                    }
21845            }
21846    
21847            protected JournalArticle getByG_C_C_PrevAndNext(Session session,
21848                    JournalArticle journalArticle, long groupId, long classNameId,
21849                    long classPK, OrderByComparator orderByComparator, boolean previous) {
21850                    StringBundler query = null;
21851    
21852                    if (orderByComparator != null) {
21853                            query = new StringBundler(6 +
21854                                            (orderByComparator.getOrderByFields().length * 6));
21855                    }
21856                    else {
21857                            query = new StringBundler(3);
21858                    }
21859    
21860                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
21861    
21862                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
21863    
21864                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
21865    
21866                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
21867    
21868                    if (orderByComparator != null) {
21869                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
21870    
21871                            if (orderByConditionFields.length > 0) {
21872                                    query.append(WHERE_AND);
21873                            }
21874    
21875                            for (int i = 0; i < orderByConditionFields.length; i++) {
21876                                    query.append(_ORDER_BY_ENTITY_ALIAS);
21877                                    query.append(orderByConditionFields[i]);
21878    
21879                                    if ((i + 1) < orderByConditionFields.length) {
21880                                            if (orderByComparator.isAscending() ^ previous) {
21881                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
21882                                            }
21883                                            else {
21884                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
21885                                            }
21886                                    }
21887                                    else {
21888                                            if (orderByComparator.isAscending() ^ previous) {
21889                                                    query.append(WHERE_GREATER_THAN);
21890                                            }
21891                                            else {
21892                                                    query.append(WHERE_LESSER_THAN);
21893                                            }
21894                                    }
21895                            }
21896    
21897                            query.append(ORDER_BY_CLAUSE);
21898    
21899                            String[] orderByFields = orderByComparator.getOrderByFields();
21900    
21901                            for (int i = 0; i < orderByFields.length; i++) {
21902                                    query.append(_ORDER_BY_ENTITY_ALIAS);
21903                                    query.append(orderByFields[i]);
21904    
21905                                    if ((i + 1) < orderByFields.length) {
21906                                            if (orderByComparator.isAscending() ^ previous) {
21907                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
21908                                            }
21909                                            else {
21910                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
21911                                            }
21912                                    }
21913                                    else {
21914                                            if (orderByComparator.isAscending() ^ previous) {
21915                                                    query.append(ORDER_BY_ASC);
21916                                            }
21917                                            else {
21918                                                    query.append(ORDER_BY_DESC);
21919                                            }
21920                                    }
21921                            }
21922                    }
21923                    else {
21924                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21925                    }
21926    
21927                    String sql = query.toString();
21928    
21929                    Query q = session.createQuery(sql);
21930    
21931                    q.setFirstResult(0);
21932                    q.setMaxResults(2);
21933    
21934                    QueryPos qPos = QueryPos.getInstance(q);
21935    
21936                    qPos.add(groupId);
21937    
21938                    qPos.add(classNameId);
21939    
21940                    qPos.add(classPK);
21941    
21942                    if (orderByComparator != null) {
21943                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
21944    
21945                            for (Object value : values) {
21946                                    qPos.add(value);
21947                            }
21948                    }
21949    
21950                    List<JournalArticle> list = q.list();
21951    
21952                    if (list.size() == 2) {
21953                            return list.get(1);
21954                    }
21955                    else {
21956                            return null;
21957                    }
21958            }
21959    
21960            /**
21961             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21962             *
21963             * @param groupId the group ID
21964             * @param classNameId the class name ID
21965             * @param classPK the class p k
21966             * @return the matching journal articles that the user has permission to view
21967             * @throws SystemException if a system exception occurred
21968             */
21969            @Override
21970            public List<JournalArticle> filterFindByG_C_C(long groupId,
21971                    long classNameId, long classPK) throws SystemException {
21972                    return filterFindByG_C_C(groupId, classNameId, classPK,
21973                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
21974            }
21975    
21976            /**
21977             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21978             *
21979             * <p>
21980             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
21981             * </p>
21982             *
21983             * @param groupId the group ID
21984             * @param classNameId the class name ID
21985             * @param classPK the class p k
21986             * @param start the lower bound of the range of journal articles
21987             * @param end the upper bound of the range of journal articles (not inclusive)
21988             * @return the range of matching journal articles that the user has permission to view
21989             * @throws SystemException if a system exception occurred
21990             */
21991            @Override
21992            public List<JournalArticle> filterFindByG_C_C(long groupId,
21993                    long classNameId, long classPK, int start, int end)
21994                    throws SystemException {
21995                    return filterFindByG_C_C(groupId, classNameId, classPK, start, end, null);
21996            }
21997    
21998            /**
21999             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
22000             *
22001             * <p>
22002             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22003             * </p>
22004             *
22005             * @param groupId the group ID
22006             * @param classNameId the class name ID
22007             * @param classPK the class p k
22008             * @param start the lower bound of the range of journal articles
22009             * @param end the upper bound of the range of journal articles (not inclusive)
22010             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
22011             * @return the ordered range of matching journal articles that the user has permission to view
22012             * @throws SystemException if a system exception occurred
22013             */
22014            @Override
22015            public List<JournalArticle> filterFindByG_C_C(long groupId,
22016                    long classNameId, long classPK, int start, int end,
22017                    OrderByComparator orderByComparator) throws SystemException {
22018                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22019                            return findByG_C_C(groupId, classNameId, classPK, start, end,
22020                                    orderByComparator);
22021                    }
22022    
22023                    StringBundler query = null;
22024    
22025                    if (orderByComparator != null) {
22026                            query = new StringBundler(5 +
22027                                            (orderByComparator.getOrderByFields().length * 3));
22028                    }
22029                    else {
22030                            query = new StringBundler(5);
22031                    }
22032    
22033                    if (getDB().isSupportsInlineDistinct()) {
22034                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
22035                    }
22036                    else {
22037                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
22038                    }
22039    
22040                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
22041    
22042                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
22043    
22044                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
22045    
22046                    if (!getDB().isSupportsInlineDistinct()) {
22047                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
22048                    }
22049    
22050                    if (orderByComparator != null) {
22051                            if (getDB().isSupportsInlineDistinct()) {
22052                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
22053                                            orderByComparator, true);
22054                            }
22055                            else {
22056                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
22057                                            orderByComparator, true);
22058                            }
22059                    }
22060                    else {
22061                            if (getDB().isSupportsInlineDistinct()) {
22062                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22063                            }
22064                            else {
22065                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
22066                            }
22067                    }
22068    
22069                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22070                                    JournalArticle.class.getName(),
22071                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22072    
22073                    Session session = null;
22074    
22075                    try {
22076                            session = openSession();
22077    
22078                            SQLQuery q = session.createSQLQuery(sql);
22079    
22080                            if (getDB().isSupportsInlineDistinct()) {
22081                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
22082                            }
22083                            else {
22084                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
22085                            }
22086    
22087                            QueryPos qPos = QueryPos.getInstance(q);
22088    
22089                            qPos.add(groupId);
22090    
22091                            qPos.add(classNameId);
22092    
22093                            qPos.add(classPK);
22094    
22095                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
22096                                    end);
22097                    }
22098                    catch (Exception e) {
22099                            throw processException(e);
22100                    }
22101                    finally {
22102                            closeSession(session);
22103                    }
22104            }
22105    
22106            /**
22107             * 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;.
22108             *
22109             * @param id the primary key of the current journal article
22110             * @param groupId the group ID
22111             * @param classNameId the class name ID
22112             * @param classPK the class p k
22113             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22114             * @return the previous, current, and next journal article
22115             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
22116             * @throws SystemException if a system exception occurred
22117             */
22118            @Override
22119            public JournalArticle[] filterFindByG_C_C_PrevAndNext(long id,
22120                    long groupId, long classNameId, long classPK,
22121                    OrderByComparator orderByComparator)
22122                    throws NoSuchArticleException, SystemException {
22123                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22124                            return findByG_C_C_PrevAndNext(id, groupId, classNameId, classPK,
22125                                    orderByComparator);
22126                    }
22127    
22128                    JournalArticle journalArticle = findByPrimaryKey(id);
22129    
22130                    Session session = null;
22131    
22132                    try {
22133                            session = openSession();
22134    
22135                            JournalArticle[] array = new JournalArticleImpl[3];
22136    
22137                            array[0] = filterGetByG_C_C_PrevAndNext(session, journalArticle,
22138                                            groupId, classNameId, classPK, orderByComparator, true);
22139    
22140                            array[1] = journalArticle;
22141    
22142                            array[2] = filterGetByG_C_C_PrevAndNext(session, journalArticle,
22143                                            groupId, classNameId, classPK, orderByComparator, false);
22144    
22145                            return array;
22146                    }
22147                    catch (Exception e) {
22148                            throw processException(e);
22149                    }
22150                    finally {
22151                            closeSession(session);
22152                    }
22153            }
22154    
22155            protected JournalArticle filterGetByG_C_C_PrevAndNext(Session session,
22156                    JournalArticle journalArticle, long groupId, long classNameId,
22157                    long classPK, OrderByComparator orderByComparator, boolean previous) {
22158                    StringBundler query = null;
22159    
22160                    if (orderByComparator != null) {
22161                            query = new StringBundler(6 +
22162                                            (orderByComparator.getOrderByFields().length * 6));
22163                    }
22164                    else {
22165                            query = new StringBundler(3);
22166                    }
22167    
22168                    if (getDB().isSupportsInlineDistinct()) {
22169                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
22170                    }
22171                    else {
22172                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
22173                    }
22174    
22175                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
22176    
22177                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
22178    
22179                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
22180    
22181                    if (!getDB().isSupportsInlineDistinct()) {
22182                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
22183                    }
22184    
22185                    if (orderByComparator != null) {
22186                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
22187    
22188                            if (orderByConditionFields.length > 0) {
22189                                    query.append(WHERE_AND);
22190                            }
22191    
22192                            for (int i = 0; i < orderByConditionFields.length; i++) {
22193                                    if (getDB().isSupportsInlineDistinct()) {
22194                                            query.append(_ORDER_BY_ENTITY_ALIAS);
22195                                    }
22196                                    else {
22197                                            query.append(_ORDER_BY_ENTITY_TABLE);
22198                                    }
22199    
22200                                    query.append(orderByConditionFields[i]);
22201    
22202                                    if ((i + 1) < orderByConditionFields.length) {
22203                                            if (orderByComparator.isAscending() ^ previous) {
22204                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
22205                                            }
22206                                            else {
22207                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
22208                                            }
22209                                    }
22210                                    else {
22211                                            if (orderByComparator.isAscending() ^ previous) {
22212                                                    query.append(WHERE_GREATER_THAN);
22213                                            }
22214                                            else {
22215                                                    query.append(WHERE_LESSER_THAN);
22216                                            }
22217                                    }
22218                            }
22219    
22220                            query.append(ORDER_BY_CLAUSE);
22221    
22222                            String[] orderByFields = orderByComparator.getOrderByFields();
22223    
22224                            for (int i = 0; i < orderByFields.length; i++) {
22225                                    if (getDB().isSupportsInlineDistinct()) {
22226                                            query.append(_ORDER_BY_ENTITY_ALIAS);
22227                                    }
22228                                    else {
22229                                            query.append(_ORDER_BY_ENTITY_TABLE);
22230                                    }
22231    
22232                                    query.append(orderByFields[i]);
22233    
22234                                    if ((i + 1) < orderByFields.length) {
22235                                            if (orderByComparator.isAscending() ^ previous) {
22236                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
22237                                            }
22238                                            else {
22239                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
22240                                            }
22241                                    }
22242                                    else {
22243                                            if (orderByComparator.isAscending() ^ previous) {
22244                                                    query.append(ORDER_BY_ASC);
22245                                            }
22246                                            else {
22247                                                    query.append(ORDER_BY_DESC);
22248                                            }
22249                                    }
22250                            }
22251                    }
22252                    else {
22253                            if (getDB().isSupportsInlineDistinct()) {
22254                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22255                            }
22256                            else {
22257                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
22258                            }
22259                    }
22260    
22261                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22262                                    JournalArticle.class.getName(),
22263                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22264    
22265                    SQLQuery q = session.createSQLQuery(sql);
22266    
22267                    q.setFirstResult(0);
22268                    q.setMaxResults(2);
22269    
22270                    if (getDB().isSupportsInlineDistinct()) {
22271                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
22272                    }
22273                    else {
22274                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
22275                    }
22276    
22277                    QueryPos qPos = QueryPos.getInstance(q);
22278    
22279                    qPos.add(groupId);
22280    
22281                    qPos.add(classNameId);
22282    
22283                    qPos.add(classPK);
22284    
22285                    if (orderByComparator != null) {
22286                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
22287    
22288                            for (Object value : values) {
22289                                    qPos.add(value);
22290                            }
22291                    }
22292    
22293                    List<JournalArticle> list = q.list();
22294    
22295                    if (list.size() == 2) {
22296                            return list.get(1);
22297                    }
22298                    else {
22299                            return null;
22300                    }
22301            }
22302    
22303            /**
22304             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63; from the database.
22305             *
22306             * @param groupId the group ID
22307             * @param classNameId the class name ID
22308             * @param classPK the class p k
22309             * @throws SystemException if a system exception occurred
22310             */
22311            @Override
22312            public void removeByG_C_C(long groupId, long classNameId, long classPK)
22313                    throws SystemException {
22314                    for (JournalArticle journalArticle : findByG_C_C(groupId, classNameId,
22315                                    classPK, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
22316                            remove(journalArticle);
22317                    }
22318            }
22319    
22320            /**
22321             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
22322             *
22323             * @param groupId the group ID
22324             * @param classNameId the class name ID
22325             * @param classPK the class p k
22326             * @return the number of matching journal articles
22327             * @throws SystemException if a system exception occurred
22328             */
22329            @Override
22330            public int countByG_C_C(long groupId, long classNameId, long classPK)
22331                    throws SystemException {
22332                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_C;
22333    
22334                    Object[] finderArgs = new Object[] { groupId, classNameId, classPK };
22335    
22336                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
22337                                    this);
22338    
22339                    if (count == null) {
22340                            StringBundler query = new StringBundler(4);
22341    
22342                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
22343    
22344                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
22345    
22346                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
22347    
22348                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
22349    
22350                            String sql = query.toString();
22351    
22352                            Session session = null;
22353    
22354                            try {
22355                                    session = openSession();
22356    
22357                                    Query q = session.createQuery(sql);
22358    
22359                                    QueryPos qPos = QueryPos.getInstance(q);
22360    
22361                                    qPos.add(groupId);
22362    
22363                                    qPos.add(classNameId);
22364    
22365                                    qPos.add(classPK);
22366    
22367                                    count = (Long)q.uniqueResult();
22368    
22369                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
22370                            }
22371                            catch (Exception e) {
22372                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
22373    
22374                                    throw processException(e);
22375                            }
22376                            finally {
22377                                    closeSession(session);
22378                            }
22379                    }
22380    
22381                    return count.intValue();
22382            }
22383    
22384            /**
22385             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
22386             *
22387             * @param groupId the group ID
22388             * @param classNameId the class name ID
22389             * @param classPK the class p k
22390             * @return the number of matching journal articles that the user has permission to view
22391             * @throws SystemException if a system exception occurred
22392             */
22393            @Override
22394            public int filterCountByG_C_C(long groupId, long classNameId, long classPK)
22395                    throws SystemException {
22396                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22397                            return countByG_C_C(groupId, classNameId, classPK);
22398                    }
22399    
22400                    StringBundler query = new StringBundler(4);
22401    
22402                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
22403    
22404                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
22405    
22406                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
22407    
22408                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
22409    
22410                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22411                                    JournalArticle.class.getName(),
22412                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22413    
22414                    Session session = null;
22415    
22416                    try {
22417                            session = openSession();
22418    
22419                            SQLQuery q = session.createSQLQuery(sql);
22420    
22421                            q.addScalar(COUNT_COLUMN_NAME,
22422                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
22423    
22424                            QueryPos qPos = QueryPos.getInstance(q);
22425    
22426                            qPos.add(groupId);
22427    
22428                            qPos.add(classNameId);
22429    
22430                            qPos.add(classPK);
22431    
22432                            Long count = (Long)q.uniqueResult();
22433    
22434                            return count.intValue();
22435                    }
22436                    catch (Exception e) {
22437                            throw processException(e);
22438                    }
22439                    finally {
22440                            closeSession(session);
22441                    }
22442            }
22443    
22444            private static final String _FINDER_COLUMN_G_C_C_GROUPID_2 = "journalArticle.groupId = ? AND ";
22445            private static final String _FINDER_COLUMN_G_C_C_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
22446            private static final String _FINDER_COLUMN_G_C_C_CLASSPK_2 = "journalArticle.classPK = ?";
22447            public static final FinderPath FINDER_PATH_FETCH_BY_G_C_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22448                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
22449                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_C_S",
22450                            new String[] {
22451                                    Long.class.getName(), Long.class.getName(),
22452                                    String.class.getName()
22453                            },
22454                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
22455                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
22456                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK);
22457            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22458                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
22459                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_S",
22460                            new String[] {
22461                                    Long.class.getName(), Long.class.getName(),
22462                                    String.class.getName()
22463                            });
22464    
22465            /**
22466             * 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.
22467             *
22468             * @param groupId the group ID
22469             * @param classNameId the class name ID
22470             * @param structureId the structure ID
22471             * @return the matching journal article
22472             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
22473             * @throws SystemException if a system exception occurred
22474             */
22475            @Override
22476            public JournalArticle findByG_C_S(long groupId, long classNameId,
22477                    String structureId) throws NoSuchArticleException, SystemException {
22478                    JournalArticle journalArticle = fetchByG_C_S(groupId, classNameId,
22479                                    structureId);
22480    
22481                    if (journalArticle == null) {
22482                            StringBundler msg = new StringBundler(8);
22483    
22484                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
22485    
22486                            msg.append("groupId=");
22487                            msg.append(groupId);
22488    
22489                            msg.append(", classNameId=");
22490                            msg.append(classNameId);
22491    
22492                            msg.append(", structureId=");
22493                            msg.append(structureId);
22494    
22495                            msg.append(StringPool.CLOSE_CURLY_BRACE);
22496    
22497                            if (_log.isWarnEnabled()) {
22498                                    _log.warn(msg.toString());
22499                            }
22500    
22501                            throw new NoSuchArticleException(msg.toString());
22502                    }
22503    
22504                    return journalArticle;
22505            }
22506    
22507            /**
22508             * 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.
22509             *
22510             * @param groupId the group ID
22511             * @param classNameId the class name ID
22512             * @param structureId the structure ID
22513             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
22514             * @throws SystemException if a system exception occurred
22515             */
22516            @Override
22517            public JournalArticle fetchByG_C_S(long groupId, long classNameId,
22518                    String structureId) throws SystemException {
22519                    return fetchByG_C_S(groupId, classNameId, structureId, true);
22520            }
22521    
22522            /**
22523             * 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.
22524             *
22525             * @param groupId the group ID
22526             * @param classNameId the class name ID
22527             * @param structureId the structure ID
22528             * @param retrieveFromCache whether to use the finder cache
22529             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
22530             * @throws SystemException if a system exception occurred
22531             */
22532            @Override
22533            public JournalArticle fetchByG_C_S(long groupId, long classNameId,
22534                    String structureId, boolean retrieveFromCache)
22535                    throws SystemException {
22536                    Object[] finderArgs = new Object[] { groupId, classNameId, structureId };
22537    
22538                    Object result = null;
22539    
22540                    if (retrieveFromCache) {
22541                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_C_S,
22542                                            finderArgs, this);
22543                    }
22544    
22545                    if (result instanceof JournalArticle) {
22546                            JournalArticle journalArticle = (JournalArticle)result;
22547    
22548                            if ((groupId != journalArticle.getGroupId()) ||
22549                                            (classNameId != journalArticle.getClassNameId()) ||
22550                                            !Validator.equals(structureId,
22551                                                    journalArticle.getStructureId())) {
22552                                    result = null;
22553                            }
22554                    }
22555    
22556                    if (result == null) {
22557                            StringBundler query = new StringBundler(5);
22558    
22559                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
22560    
22561                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
22562    
22563                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
22564    
22565                            boolean bindStructureId = false;
22566    
22567                            if (structureId == null) {
22568                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_1);
22569                            }
22570                            else if (structureId.equals(StringPool.BLANK)) {
22571                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_3);
22572                            }
22573                            else {
22574                                    bindStructureId = true;
22575    
22576                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_2);
22577                            }
22578    
22579                            String sql = query.toString();
22580    
22581                            Session session = null;
22582    
22583                            try {
22584                                    session = openSession();
22585    
22586                                    Query q = session.createQuery(sql);
22587    
22588                                    QueryPos qPos = QueryPos.getInstance(q);
22589    
22590                                    qPos.add(groupId);
22591    
22592                                    qPos.add(classNameId);
22593    
22594                                    if (bindStructureId) {
22595                                            qPos.add(structureId);
22596                                    }
22597    
22598                                    List<JournalArticle> list = q.list();
22599    
22600                                    if (list.isEmpty()) {
22601                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
22602                                                    finderArgs, list);
22603                                    }
22604                                    else {
22605                                            if ((list.size() > 1) && _log.isWarnEnabled()) {
22606                                                    _log.warn(
22607                                                            "JournalArticlePersistenceImpl.fetchByG_C_S(long, long, String, boolean) with parameters (" +
22608                                                            StringUtil.merge(finderArgs) +
22609                                                            ") 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.");
22610                                            }
22611    
22612                                            JournalArticle journalArticle = list.get(0);
22613    
22614                                            result = journalArticle;
22615    
22616                                            cacheResult(journalArticle);
22617    
22618                                            if ((journalArticle.getGroupId() != groupId) ||
22619                                                            (journalArticle.getClassNameId() != classNameId) ||
22620                                                            (journalArticle.getStructureId() == null) ||
22621                                                            !journalArticle.getStructureId().equals(structureId)) {
22622                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
22623                                                            finderArgs, journalArticle);
22624                                            }
22625                                    }
22626                            }
22627                            catch (Exception e) {
22628                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S,
22629                                            finderArgs);
22630    
22631                                    throw processException(e);
22632                            }
22633                            finally {
22634                                    closeSession(session);
22635                            }
22636                    }
22637    
22638                    if (result instanceof List<?>) {
22639                            return null;
22640                    }
22641                    else {
22642                            return (JournalArticle)result;
22643                    }
22644            }
22645    
22646            /**
22647             * Removes the journal article where groupId = &#63; and classNameId = &#63; and structureId = &#63; from the database.
22648             *
22649             * @param groupId the group ID
22650             * @param classNameId the class name ID
22651             * @param structureId the structure ID
22652             * @return the journal article that was removed
22653             * @throws SystemException if a system exception occurred
22654             */
22655            @Override
22656            public JournalArticle removeByG_C_S(long groupId, long classNameId,
22657                    String structureId) throws NoSuchArticleException, SystemException {
22658                    JournalArticle journalArticle = findByG_C_S(groupId, classNameId,
22659                                    structureId);
22660    
22661                    return remove(journalArticle);
22662            }
22663    
22664            /**
22665             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and structureId = &#63;.
22666             *
22667             * @param groupId the group ID
22668             * @param classNameId the class name ID
22669             * @param structureId the structure ID
22670             * @return the number of matching journal articles
22671             * @throws SystemException if a system exception occurred
22672             */
22673            @Override
22674            public int countByG_C_S(long groupId, long classNameId, String structureId)
22675                    throws SystemException {
22676                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_S;
22677    
22678                    Object[] finderArgs = new Object[] { groupId, classNameId, structureId };
22679    
22680                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
22681                                    this);
22682    
22683                    if (count == null) {
22684                            StringBundler query = new StringBundler(4);
22685    
22686                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
22687    
22688                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
22689    
22690                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
22691    
22692                            boolean bindStructureId = false;
22693    
22694                            if (structureId == null) {
22695                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_1);
22696                            }
22697                            else if (structureId.equals(StringPool.BLANK)) {
22698                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_3);
22699                            }
22700                            else {
22701                                    bindStructureId = true;
22702    
22703                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_2);
22704                            }
22705    
22706                            String sql = query.toString();
22707    
22708                            Session session = null;
22709    
22710                            try {
22711                                    session = openSession();
22712    
22713                                    Query q = session.createQuery(sql);
22714    
22715                                    QueryPos qPos = QueryPos.getInstance(q);
22716    
22717                                    qPos.add(groupId);
22718    
22719                                    qPos.add(classNameId);
22720    
22721                                    if (bindStructureId) {
22722                                            qPos.add(structureId);
22723                                    }
22724    
22725                                    count = (Long)q.uniqueResult();
22726    
22727                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
22728                            }
22729                            catch (Exception e) {
22730                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
22731    
22732                                    throw processException(e);
22733                            }
22734                            finally {
22735                                    closeSession(session);
22736                            }
22737                    }
22738    
22739                    return count.intValue();
22740            }
22741    
22742            private static final String _FINDER_COLUMN_G_C_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
22743            private static final String _FINDER_COLUMN_G_C_S_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
22744            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
22745            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
22746            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = '')";
22747            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22748                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
22749                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
22750                            "findByG_C_T",
22751                            new String[] {
22752                                    Long.class.getName(), Long.class.getName(),
22753                                    String.class.getName(),
22754                                    
22755                            Integer.class.getName(), Integer.class.getName(),
22756                                    OrderByComparator.class.getName()
22757                            });
22758            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22759                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
22760                            JournalArticleImpl.class,
22761                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_T",
22762                            new String[] {
22763                                    Long.class.getName(), Long.class.getName(),
22764                                    String.class.getName()
22765                            },
22766                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
22767                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
22768                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK |
22769                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
22770                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
22771            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22772                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
22773                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_T",
22774                            new String[] {
22775                                    Long.class.getName(), Long.class.getName(),
22776                                    String.class.getName()
22777                            });
22778    
22779            /**
22780             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
22781             *
22782             * @param groupId the group ID
22783             * @param classNameId the class name ID
22784             * @param templateId the template ID
22785             * @return the matching journal articles
22786             * @throws SystemException if a system exception occurred
22787             */
22788            @Override
22789            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
22790                    String templateId) throws SystemException {
22791                    return findByG_C_T(groupId, classNameId, templateId, QueryUtil.ALL_POS,
22792                            QueryUtil.ALL_POS, null);
22793            }
22794    
22795            /**
22796             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
22797             *
22798             * <p>
22799             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22800             * </p>
22801             *
22802             * @param groupId the group ID
22803             * @param classNameId the class name ID
22804             * @param templateId the template ID
22805             * @param start the lower bound of the range of journal articles
22806             * @param end the upper bound of the range of journal articles (not inclusive)
22807             * @return the range of matching journal articles
22808             * @throws SystemException if a system exception occurred
22809             */
22810            @Override
22811            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
22812                    String templateId, int start, int end) throws SystemException {
22813                    return findByG_C_T(groupId, classNameId, templateId, start, end, null);
22814            }
22815    
22816            /**
22817             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
22818             *
22819             * <p>
22820             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22821             * </p>
22822             *
22823             * @param groupId the group ID
22824             * @param classNameId the class name ID
22825             * @param templateId the template ID
22826             * @param start the lower bound of the range of journal articles
22827             * @param end the upper bound of the range of journal articles (not inclusive)
22828             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
22829             * @return the ordered range of matching journal articles
22830             * @throws SystemException if a system exception occurred
22831             */
22832            @Override
22833            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
22834                    String templateId, int start, int end,
22835                    OrderByComparator orderByComparator) throws SystemException {
22836                    boolean pagination = true;
22837                    FinderPath finderPath = null;
22838                    Object[] finderArgs = null;
22839    
22840                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
22841                                    (orderByComparator == null)) {
22842                            pagination = false;
22843                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T;
22844                            finderArgs = new Object[] { groupId, classNameId, templateId };
22845                    }
22846                    else {
22847                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T;
22848                            finderArgs = new Object[] {
22849                                            groupId, classNameId, templateId,
22850                                            
22851                                            start, end, orderByComparator
22852                                    };
22853                    }
22854    
22855                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
22856                                    finderArgs, this);
22857    
22858                    if ((list != null) && !list.isEmpty()) {
22859                            for (JournalArticle journalArticle : list) {
22860                                    if ((groupId != journalArticle.getGroupId()) ||
22861                                                    (classNameId != journalArticle.getClassNameId()) ||
22862                                                    !Validator.equals(templateId,
22863                                                            journalArticle.getTemplateId())) {
22864                                            list = null;
22865    
22866                                            break;
22867                                    }
22868                            }
22869                    }
22870    
22871                    if (list == null) {
22872                            StringBundler query = null;
22873    
22874                            if (orderByComparator != null) {
22875                                    query = new StringBundler(5 +
22876                                                    (orderByComparator.getOrderByFields().length * 3));
22877                            }
22878                            else {
22879                                    query = new StringBundler(5);
22880                            }
22881    
22882                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
22883    
22884                            query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
22885    
22886                            query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
22887    
22888                            boolean bindTemplateId = false;
22889    
22890                            if (templateId == null) {
22891                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
22892                            }
22893                            else if (templateId.equals(StringPool.BLANK)) {
22894                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
22895                            }
22896                            else {
22897                                    bindTemplateId = true;
22898    
22899                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
22900                            }
22901    
22902                            if (orderByComparator != null) {
22903                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
22904                                            orderByComparator);
22905                            }
22906                            else
22907                             if (pagination) {
22908                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22909                            }
22910    
22911                            String sql = query.toString();
22912    
22913                            Session session = null;
22914    
22915                            try {
22916                                    session = openSession();
22917    
22918                                    Query q = session.createQuery(sql);
22919    
22920                                    QueryPos qPos = QueryPos.getInstance(q);
22921    
22922                                    qPos.add(groupId);
22923    
22924                                    qPos.add(classNameId);
22925    
22926                                    if (bindTemplateId) {
22927                                            qPos.add(templateId);
22928                                    }
22929    
22930                                    if (!pagination) {
22931                                            list = (List<JournalArticle>)QueryUtil.list(q,
22932                                                            getDialect(), start, end, false);
22933    
22934                                            Collections.sort(list);
22935    
22936                                            list = new UnmodifiableList<JournalArticle>(list);
22937                                    }
22938                                    else {
22939                                            list = (List<JournalArticle>)QueryUtil.list(q,
22940                                                            getDialect(), start, end);
22941                                    }
22942    
22943                                    cacheResult(list);
22944    
22945                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
22946                            }
22947                            catch (Exception e) {
22948                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
22949    
22950                                    throw processException(e);
22951                            }
22952                            finally {
22953                                    closeSession(session);
22954                            }
22955                    }
22956    
22957                    return list;
22958            }
22959    
22960            /**
22961             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
22962             *
22963             * @param groupId the group ID
22964             * @param classNameId the class name ID
22965             * @param templateId the template ID
22966             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22967             * @return the first matching journal article
22968             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
22969             * @throws SystemException if a system exception occurred
22970             */
22971            @Override
22972            public JournalArticle findByG_C_T_First(long groupId, long classNameId,
22973                    String templateId, OrderByComparator orderByComparator)
22974                    throws NoSuchArticleException, SystemException {
22975                    JournalArticle journalArticle = fetchByG_C_T_First(groupId,
22976                                    classNameId, templateId, orderByComparator);
22977    
22978                    if (journalArticle != null) {
22979                            return journalArticle;
22980                    }
22981    
22982                    StringBundler msg = new StringBundler(8);
22983    
22984                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
22985    
22986                    msg.append("groupId=");
22987                    msg.append(groupId);
22988    
22989                    msg.append(", classNameId=");
22990                    msg.append(classNameId);
22991    
22992                    msg.append(", templateId=");
22993                    msg.append(templateId);
22994    
22995                    msg.append(StringPool.CLOSE_CURLY_BRACE);
22996    
22997                    throw new NoSuchArticleException(msg.toString());
22998            }
22999    
23000            /**
23001             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
23002             *
23003             * @param groupId the group ID
23004             * @param classNameId the class name ID
23005             * @param templateId the template ID
23006             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23007             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
23008             * @throws SystemException if a system exception occurred
23009             */
23010            @Override
23011            public JournalArticle fetchByG_C_T_First(long groupId, long classNameId,
23012                    String templateId, OrderByComparator orderByComparator)
23013                    throws SystemException {
23014                    List<JournalArticle> list = findByG_C_T(groupId, classNameId,
23015                                    templateId, 0, 1, orderByComparator);
23016    
23017                    if (!list.isEmpty()) {
23018                            return list.get(0);
23019                    }
23020    
23021                    return null;
23022            }
23023    
23024            /**
23025             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
23026             *
23027             * @param groupId the group ID
23028             * @param classNameId the class name ID
23029             * @param templateId the template ID
23030             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23031             * @return the last matching journal article
23032             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
23033             * @throws SystemException if a system exception occurred
23034             */
23035            @Override
23036            public JournalArticle findByG_C_T_Last(long groupId, long classNameId,
23037                    String templateId, OrderByComparator orderByComparator)
23038                    throws NoSuchArticleException, SystemException {
23039                    JournalArticle journalArticle = fetchByG_C_T_Last(groupId, classNameId,
23040                                    templateId, orderByComparator);
23041    
23042                    if (journalArticle != null) {
23043                            return journalArticle;
23044                    }
23045    
23046                    StringBundler msg = new StringBundler(8);
23047    
23048                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
23049    
23050                    msg.append("groupId=");
23051                    msg.append(groupId);
23052    
23053                    msg.append(", classNameId=");
23054                    msg.append(classNameId);
23055    
23056                    msg.append(", templateId=");
23057                    msg.append(templateId);
23058    
23059                    msg.append(StringPool.CLOSE_CURLY_BRACE);
23060    
23061                    throw new NoSuchArticleException(msg.toString());
23062            }
23063    
23064            /**
23065             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
23066             *
23067             * @param groupId the group ID
23068             * @param classNameId the class name ID
23069             * @param templateId the template ID
23070             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23071             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
23072             * @throws SystemException if a system exception occurred
23073             */
23074            @Override
23075            public JournalArticle fetchByG_C_T_Last(long groupId, long classNameId,
23076                    String templateId, OrderByComparator orderByComparator)
23077                    throws SystemException {
23078                    int count = countByG_C_T(groupId, classNameId, templateId);
23079    
23080                    if (count == 0) {
23081                            return null;
23082                    }
23083    
23084                    List<JournalArticle> list = findByG_C_T(groupId, classNameId,
23085                                    templateId, count - 1, count, orderByComparator);
23086    
23087                    if (!list.isEmpty()) {
23088                            return list.get(0);
23089                    }
23090    
23091                    return null;
23092            }
23093    
23094            /**
23095             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
23096             *
23097             * @param id the primary key of the current journal article
23098             * @param groupId the group ID
23099             * @param classNameId the class name ID
23100             * @param templateId the template ID
23101             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23102             * @return the previous, current, and next journal article
23103             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
23104             * @throws SystemException if a system exception occurred
23105             */
23106            @Override
23107            public JournalArticle[] findByG_C_T_PrevAndNext(long id, long groupId,
23108                    long classNameId, String templateId, OrderByComparator orderByComparator)
23109                    throws NoSuchArticleException, SystemException {
23110                    JournalArticle journalArticle = findByPrimaryKey(id);
23111    
23112                    Session session = null;
23113    
23114                    try {
23115                            session = openSession();
23116    
23117                            JournalArticle[] array = new JournalArticleImpl[3];
23118    
23119                            array[0] = getByG_C_T_PrevAndNext(session, journalArticle, groupId,
23120                                            classNameId, templateId, orderByComparator, true);
23121    
23122                            array[1] = journalArticle;
23123    
23124                            array[2] = getByG_C_T_PrevAndNext(session, journalArticle, groupId,
23125                                            classNameId, templateId, orderByComparator, false);
23126    
23127                            return array;
23128                    }
23129                    catch (Exception e) {
23130                            throw processException(e);
23131                    }
23132                    finally {
23133                            closeSession(session);
23134                    }
23135            }
23136    
23137            protected JournalArticle getByG_C_T_PrevAndNext(Session session,
23138                    JournalArticle journalArticle, long groupId, long classNameId,
23139                    String templateId, OrderByComparator orderByComparator, boolean previous) {
23140                    StringBundler query = null;
23141    
23142                    if (orderByComparator != null) {
23143                            query = new StringBundler(6 +
23144                                            (orderByComparator.getOrderByFields().length * 6));
23145                    }
23146                    else {
23147                            query = new StringBundler(3);
23148                    }
23149    
23150                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
23151    
23152                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
23153    
23154                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
23155    
23156                    boolean bindTemplateId = false;
23157    
23158                    if (templateId == null) {
23159                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
23160                    }
23161                    else if (templateId.equals(StringPool.BLANK)) {
23162                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
23163                    }
23164                    else {
23165                            bindTemplateId = true;
23166    
23167                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
23168                    }
23169    
23170                    if (orderByComparator != null) {
23171                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
23172    
23173                            if (orderByConditionFields.length > 0) {
23174                                    query.append(WHERE_AND);
23175                            }
23176    
23177                            for (int i = 0; i < orderByConditionFields.length; i++) {
23178                                    query.append(_ORDER_BY_ENTITY_ALIAS);
23179                                    query.append(orderByConditionFields[i]);
23180    
23181                                    if ((i + 1) < orderByConditionFields.length) {
23182                                            if (orderByComparator.isAscending() ^ previous) {
23183                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
23184                                            }
23185                                            else {
23186                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
23187                                            }
23188                                    }
23189                                    else {
23190                                            if (orderByComparator.isAscending() ^ previous) {
23191                                                    query.append(WHERE_GREATER_THAN);
23192                                            }
23193                                            else {
23194                                                    query.append(WHERE_LESSER_THAN);
23195                                            }
23196                                    }
23197                            }
23198    
23199                            query.append(ORDER_BY_CLAUSE);
23200    
23201                            String[] orderByFields = orderByComparator.getOrderByFields();
23202    
23203                            for (int i = 0; i < orderByFields.length; i++) {
23204                                    query.append(_ORDER_BY_ENTITY_ALIAS);
23205                                    query.append(orderByFields[i]);
23206    
23207                                    if ((i + 1) < orderByFields.length) {
23208                                            if (orderByComparator.isAscending() ^ previous) {
23209                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
23210                                            }
23211                                            else {
23212                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
23213                                            }
23214                                    }
23215                                    else {
23216                                            if (orderByComparator.isAscending() ^ previous) {
23217                                                    query.append(ORDER_BY_ASC);
23218                                            }
23219                                            else {
23220                                                    query.append(ORDER_BY_DESC);
23221                                            }
23222                                    }
23223                            }
23224                    }
23225                    else {
23226                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23227                    }
23228    
23229                    String sql = query.toString();
23230    
23231                    Query q = session.createQuery(sql);
23232    
23233                    q.setFirstResult(0);
23234                    q.setMaxResults(2);
23235    
23236                    QueryPos qPos = QueryPos.getInstance(q);
23237    
23238                    qPos.add(groupId);
23239    
23240                    qPos.add(classNameId);
23241    
23242                    if (bindTemplateId) {
23243                            qPos.add(templateId);
23244                    }
23245    
23246                    if (orderByComparator != null) {
23247                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
23248    
23249                            for (Object value : values) {
23250                                    qPos.add(value);
23251                            }
23252                    }
23253    
23254                    List<JournalArticle> list = q.list();
23255    
23256                    if (list.size() == 2) {
23257                            return list.get(1);
23258                    }
23259                    else {
23260                            return null;
23261                    }
23262            }
23263    
23264            /**
23265             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
23266             *
23267             * @param groupId the group ID
23268             * @param classNameId the class name ID
23269             * @param templateId the template ID
23270             * @return the matching journal articles that the user has permission to view
23271             * @throws SystemException if a system exception occurred
23272             */
23273            @Override
23274            public List<JournalArticle> filterFindByG_C_T(long groupId,
23275                    long classNameId, String templateId) throws SystemException {
23276                    return filterFindByG_C_T(groupId, classNameId, templateId,
23277                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
23278            }
23279    
23280            /**
23281             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
23282             *
23283             * <p>
23284             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23285             * </p>
23286             *
23287             * @param groupId the group ID
23288             * @param classNameId the class name ID
23289             * @param templateId the template ID
23290             * @param start the lower bound of the range of journal articles
23291             * @param end the upper bound of the range of journal articles (not inclusive)
23292             * @return the range of matching journal articles that the user has permission to view
23293             * @throws SystemException if a system exception occurred
23294             */
23295            @Override
23296            public List<JournalArticle> filterFindByG_C_T(long groupId,
23297                    long classNameId, String templateId, int start, int end)
23298                    throws SystemException {
23299                    return filterFindByG_C_T(groupId, classNameId, templateId, start, end,
23300                            null);
23301            }
23302    
23303            /**
23304             * 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;.
23305             *
23306             * <p>
23307             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23308             * </p>
23309             *
23310             * @param groupId the group ID
23311             * @param classNameId the class name ID
23312             * @param templateId the template ID
23313             * @param start the lower bound of the range of journal articles
23314             * @param end the upper bound of the range of journal articles (not inclusive)
23315             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
23316             * @return the ordered range of matching journal articles that the user has permission to view
23317             * @throws SystemException if a system exception occurred
23318             */
23319            @Override
23320            public List<JournalArticle> filterFindByG_C_T(long groupId,
23321                    long classNameId, String templateId, int start, int end,
23322                    OrderByComparator orderByComparator) throws SystemException {
23323                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23324                            return findByG_C_T(groupId, classNameId, templateId, start, end,
23325                                    orderByComparator);
23326                    }
23327    
23328                    StringBundler query = null;
23329    
23330                    if (orderByComparator != null) {
23331                            query = new StringBundler(5 +
23332                                            (orderByComparator.getOrderByFields().length * 3));
23333                    }
23334                    else {
23335                            query = new StringBundler(5);
23336                    }
23337    
23338                    if (getDB().isSupportsInlineDistinct()) {
23339                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
23340                    }
23341                    else {
23342                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
23343                    }
23344    
23345                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
23346    
23347                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
23348    
23349                    boolean bindTemplateId = false;
23350    
23351                    if (templateId == null) {
23352                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
23353                    }
23354                    else if (templateId.equals(StringPool.BLANK)) {
23355                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
23356                    }
23357                    else {
23358                            bindTemplateId = true;
23359    
23360                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
23361                    }
23362    
23363                    if (!getDB().isSupportsInlineDistinct()) {
23364                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
23365                    }
23366    
23367                    if (orderByComparator != null) {
23368                            if (getDB().isSupportsInlineDistinct()) {
23369                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
23370                                            orderByComparator, true);
23371                            }
23372                            else {
23373                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
23374                                            orderByComparator, true);
23375                            }
23376                    }
23377                    else {
23378                            if (getDB().isSupportsInlineDistinct()) {
23379                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23380                            }
23381                            else {
23382                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
23383                            }
23384                    }
23385    
23386                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23387                                    JournalArticle.class.getName(),
23388                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23389    
23390                    Session session = null;
23391    
23392                    try {
23393                            session = openSession();
23394    
23395                            SQLQuery q = session.createSQLQuery(sql);
23396    
23397                            if (getDB().isSupportsInlineDistinct()) {
23398                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
23399                            }
23400                            else {
23401                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
23402                            }
23403    
23404                            QueryPos qPos = QueryPos.getInstance(q);
23405    
23406                            qPos.add(groupId);
23407    
23408                            qPos.add(classNameId);
23409    
23410                            if (bindTemplateId) {
23411                                    qPos.add(templateId);
23412                            }
23413    
23414                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
23415                                    end);
23416                    }
23417                    catch (Exception e) {
23418                            throw processException(e);
23419                    }
23420                    finally {
23421                            closeSession(session);
23422                    }
23423            }
23424    
23425            /**
23426             * 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;.
23427             *
23428             * @param id the primary key of the current journal article
23429             * @param groupId the group ID
23430             * @param classNameId the class name ID
23431             * @param templateId the template ID
23432             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23433             * @return the previous, current, and next journal article
23434             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
23435             * @throws SystemException if a system exception occurred
23436             */
23437            @Override
23438            public JournalArticle[] filterFindByG_C_T_PrevAndNext(long id,
23439                    long groupId, long classNameId, String templateId,
23440                    OrderByComparator orderByComparator)
23441                    throws NoSuchArticleException, SystemException {
23442                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23443                            return findByG_C_T_PrevAndNext(id, groupId, classNameId,
23444                                    templateId, orderByComparator);
23445                    }
23446    
23447                    JournalArticle journalArticle = findByPrimaryKey(id);
23448    
23449                    Session session = null;
23450    
23451                    try {
23452                            session = openSession();
23453    
23454                            JournalArticle[] array = new JournalArticleImpl[3];
23455    
23456                            array[0] = filterGetByG_C_T_PrevAndNext(session, journalArticle,
23457                                            groupId, classNameId, templateId, orderByComparator, true);
23458    
23459                            array[1] = journalArticle;
23460    
23461                            array[2] = filterGetByG_C_T_PrevAndNext(session, journalArticle,
23462                                            groupId, classNameId, templateId, orderByComparator, false);
23463    
23464                            return array;
23465                    }
23466                    catch (Exception e) {
23467                            throw processException(e);
23468                    }
23469                    finally {
23470                            closeSession(session);
23471                    }
23472            }
23473    
23474            protected JournalArticle filterGetByG_C_T_PrevAndNext(Session session,
23475                    JournalArticle journalArticle, long groupId, long classNameId,
23476                    String templateId, OrderByComparator orderByComparator, boolean previous) {
23477                    StringBundler query = null;
23478    
23479                    if (orderByComparator != null) {
23480                            query = new StringBundler(6 +
23481                                            (orderByComparator.getOrderByFields().length * 6));
23482                    }
23483                    else {
23484                            query = new StringBundler(3);
23485                    }
23486    
23487                    if (getDB().isSupportsInlineDistinct()) {
23488                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
23489                    }
23490                    else {
23491                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
23492                    }
23493    
23494                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
23495    
23496                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
23497    
23498                    boolean bindTemplateId = false;
23499    
23500                    if (templateId == null) {
23501                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
23502                    }
23503                    else if (templateId.equals(StringPool.BLANK)) {
23504                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
23505                    }
23506                    else {
23507                            bindTemplateId = true;
23508    
23509                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
23510                    }
23511    
23512                    if (!getDB().isSupportsInlineDistinct()) {
23513                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
23514                    }
23515    
23516                    if (orderByComparator != null) {
23517                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
23518    
23519                            if (orderByConditionFields.length > 0) {
23520                                    query.append(WHERE_AND);
23521                            }
23522    
23523                            for (int i = 0; i < orderByConditionFields.length; i++) {
23524                                    if (getDB().isSupportsInlineDistinct()) {
23525                                            query.append(_ORDER_BY_ENTITY_ALIAS);
23526                                    }
23527                                    else {
23528                                            query.append(_ORDER_BY_ENTITY_TABLE);
23529                                    }
23530    
23531                                    query.append(orderByConditionFields[i]);
23532    
23533                                    if ((i + 1) < orderByConditionFields.length) {
23534                                            if (orderByComparator.isAscending() ^ previous) {
23535                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
23536                                            }
23537                                            else {
23538                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
23539                                            }
23540                                    }
23541                                    else {
23542                                            if (orderByComparator.isAscending() ^ previous) {
23543                                                    query.append(WHERE_GREATER_THAN);
23544                                            }
23545                                            else {
23546                                                    query.append(WHERE_LESSER_THAN);
23547                                            }
23548                                    }
23549                            }
23550    
23551                            query.append(ORDER_BY_CLAUSE);
23552    
23553                            String[] orderByFields = orderByComparator.getOrderByFields();
23554    
23555                            for (int i = 0; i < orderByFields.length; i++) {
23556                                    if (getDB().isSupportsInlineDistinct()) {
23557                                            query.append(_ORDER_BY_ENTITY_ALIAS);
23558                                    }
23559                                    else {
23560                                            query.append(_ORDER_BY_ENTITY_TABLE);
23561                                    }
23562    
23563                                    query.append(orderByFields[i]);
23564    
23565                                    if ((i + 1) < orderByFields.length) {
23566                                            if (orderByComparator.isAscending() ^ previous) {
23567                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
23568                                            }
23569                                            else {
23570                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
23571                                            }
23572                                    }
23573                                    else {
23574                                            if (orderByComparator.isAscending() ^ previous) {
23575                                                    query.append(ORDER_BY_ASC);
23576                                            }
23577                                            else {
23578                                                    query.append(ORDER_BY_DESC);
23579                                            }
23580                                    }
23581                            }
23582                    }
23583                    else {
23584                            if (getDB().isSupportsInlineDistinct()) {
23585                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23586                            }
23587                            else {
23588                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
23589                            }
23590                    }
23591    
23592                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23593                                    JournalArticle.class.getName(),
23594                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23595    
23596                    SQLQuery q = session.createSQLQuery(sql);
23597    
23598                    q.setFirstResult(0);
23599                    q.setMaxResults(2);
23600    
23601                    if (getDB().isSupportsInlineDistinct()) {
23602                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
23603                    }
23604                    else {
23605                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
23606                    }
23607    
23608                    QueryPos qPos = QueryPos.getInstance(q);
23609    
23610                    qPos.add(groupId);
23611    
23612                    qPos.add(classNameId);
23613    
23614                    if (bindTemplateId) {
23615                            qPos.add(templateId);
23616                    }
23617    
23618                    if (orderByComparator != null) {
23619                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
23620    
23621                            for (Object value : values) {
23622                                    qPos.add(value);
23623                            }
23624                    }
23625    
23626                    List<JournalArticle> list = q.list();
23627    
23628                    if (list.size() == 2) {
23629                            return list.get(1);
23630                    }
23631                    else {
23632                            return null;
23633                    }
23634            }
23635    
23636            /**
23637             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63; from the database.
23638             *
23639             * @param groupId the group ID
23640             * @param classNameId the class name ID
23641             * @param templateId the template ID
23642             * @throws SystemException if a system exception occurred
23643             */
23644            @Override
23645            public void removeByG_C_T(long groupId, long classNameId, String templateId)
23646                    throws SystemException {
23647                    for (JournalArticle journalArticle : findByG_C_T(groupId, classNameId,
23648                                    templateId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
23649                            remove(journalArticle);
23650                    }
23651            }
23652    
23653            /**
23654             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
23655             *
23656             * @param groupId the group ID
23657             * @param classNameId the class name ID
23658             * @param templateId the template ID
23659             * @return the number of matching journal articles
23660             * @throws SystemException if a system exception occurred
23661             */
23662            @Override
23663            public int countByG_C_T(long groupId, long classNameId, String templateId)
23664                    throws SystemException {
23665                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_T;
23666    
23667                    Object[] finderArgs = new Object[] { groupId, classNameId, templateId };
23668    
23669                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
23670                                    this);
23671    
23672                    if (count == null) {
23673                            StringBundler query = new StringBundler(4);
23674    
23675                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
23676    
23677                            query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
23678    
23679                            query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
23680    
23681                            boolean bindTemplateId = false;
23682    
23683                            if (templateId == null) {
23684                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
23685                            }
23686                            else if (templateId.equals(StringPool.BLANK)) {
23687                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
23688                            }
23689                            else {
23690                                    bindTemplateId = true;
23691    
23692                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
23693                            }
23694    
23695                            String sql = query.toString();
23696    
23697                            Session session = null;
23698    
23699                            try {
23700                                    session = openSession();
23701    
23702                                    Query q = session.createQuery(sql);
23703    
23704                                    QueryPos qPos = QueryPos.getInstance(q);
23705    
23706                                    qPos.add(groupId);
23707    
23708                                    qPos.add(classNameId);
23709    
23710                                    if (bindTemplateId) {
23711                                            qPos.add(templateId);
23712                                    }
23713    
23714                                    count = (Long)q.uniqueResult();
23715    
23716                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
23717                            }
23718                            catch (Exception e) {
23719                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
23720    
23721                                    throw processException(e);
23722                            }
23723                            finally {
23724                                    closeSession(session);
23725                            }
23726                    }
23727    
23728                    return count.intValue();
23729            }
23730    
23731            /**
23732             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
23733             *
23734             * @param groupId the group ID
23735             * @param classNameId the class name ID
23736             * @param templateId the template ID
23737             * @return the number of matching journal articles that the user has permission to view
23738             * @throws SystemException if a system exception occurred
23739             */
23740            @Override
23741            public int filterCountByG_C_T(long groupId, long classNameId,
23742                    String templateId) throws SystemException {
23743                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23744                            return countByG_C_T(groupId, classNameId, templateId);
23745                    }
23746    
23747                    StringBundler query = new StringBundler(4);
23748    
23749                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
23750    
23751                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
23752    
23753                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
23754    
23755                    boolean bindTemplateId = false;
23756    
23757                    if (templateId == null) {
23758                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
23759                    }
23760                    else if (templateId.equals(StringPool.BLANK)) {
23761                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
23762                    }
23763                    else {
23764                            bindTemplateId = true;
23765    
23766                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
23767                    }
23768    
23769                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23770                                    JournalArticle.class.getName(),
23771                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23772    
23773                    Session session = null;
23774    
23775                    try {
23776                            session = openSession();
23777    
23778                            SQLQuery q = session.createSQLQuery(sql);
23779    
23780                            q.addScalar(COUNT_COLUMN_NAME,
23781                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
23782    
23783                            QueryPos qPos = QueryPos.getInstance(q);
23784    
23785                            qPos.add(groupId);
23786    
23787                            qPos.add(classNameId);
23788    
23789                            if (bindTemplateId) {
23790                                    qPos.add(templateId);
23791                            }
23792    
23793                            Long count = (Long)q.uniqueResult();
23794    
23795                            return count.intValue();
23796                    }
23797                    catch (Exception e) {
23798                            throw processException(e);
23799                    }
23800                    finally {
23801                            closeSession(session);
23802                    }
23803            }
23804    
23805            private static final String _FINDER_COLUMN_G_C_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
23806            private static final String _FINDER_COLUMN_G_C_T_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
23807            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
23808            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
23809            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = '')";
23810            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23811                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
23812                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
23813                            "findByG_C_L",
23814                            new String[] {
23815                                    Long.class.getName(), Long.class.getName(),
23816                                    String.class.getName(),
23817                                    
23818                            Integer.class.getName(), Integer.class.getName(),
23819                                    OrderByComparator.class.getName()
23820                            });
23821            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23822                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
23823                            JournalArticleImpl.class,
23824                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_L",
23825                            new String[] {
23826                                    Long.class.getName(), Long.class.getName(),
23827                                    String.class.getName()
23828                            },
23829                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
23830                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
23831                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK |
23832                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
23833                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
23834            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23835                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
23836                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_L",
23837                            new String[] {
23838                                    Long.class.getName(), Long.class.getName(),
23839                                    String.class.getName()
23840                            });
23841    
23842            /**
23843             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23844             *
23845             * @param groupId the group ID
23846             * @param classNameId the class name ID
23847             * @param layoutUuid the layout uuid
23848             * @return the matching journal articles
23849             * @throws SystemException if a system exception occurred
23850             */
23851            @Override
23852            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
23853                    String layoutUuid) throws SystemException {
23854                    return findByG_C_L(groupId, classNameId, layoutUuid, QueryUtil.ALL_POS,
23855                            QueryUtil.ALL_POS, null);
23856            }
23857    
23858            /**
23859             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23860             *
23861             * <p>
23862             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23863             * </p>
23864             *
23865             * @param groupId the group ID
23866             * @param classNameId the class name ID
23867             * @param layoutUuid the layout uuid
23868             * @param start the lower bound of the range of journal articles
23869             * @param end the upper bound of the range of journal articles (not inclusive)
23870             * @return the range of matching journal articles
23871             * @throws SystemException if a system exception occurred
23872             */
23873            @Override
23874            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
23875                    String layoutUuid, int start, int end) throws SystemException {
23876                    return findByG_C_L(groupId, classNameId, layoutUuid, start, end, null);
23877            }
23878    
23879            /**
23880             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23881             *
23882             * <p>
23883             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23884             * </p>
23885             *
23886             * @param groupId the group ID
23887             * @param classNameId the class name ID
23888             * @param layoutUuid the layout uuid
23889             * @param start the lower bound of the range of journal articles
23890             * @param end the upper bound of the range of journal articles (not inclusive)
23891             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
23892             * @return the ordered range of matching journal articles
23893             * @throws SystemException if a system exception occurred
23894             */
23895            @Override
23896            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
23897                    String layoutUuid, int start, int end,
23898                    OrderByComparator orderByComparator) throws SystemException {
23899                    boolean pagination = true;
23900                    FinderPath finderPath = null;
23901                    Object[] finderArgs = null;
23902    
23903                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
23904                                    (orderByComparator == null)) {
23905                            pagination = false;
23906                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L;
23907                            finderArgs = new Object[] { groupId, classNameId, layoutUuid };
23908                    }
23909                    else {
23910                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L;
23911                            finderArgs = new Object[] {
23912                                            groupId, classNameId, layoutUuid,
23913                                            
23914                                            start, end, orderByComparator
23915                                    };
23916                    }
23917    
23918                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
23919                                    finderArgs, this);
23920    
23921                    if ((list != null) && !list.isEmpty()) {
23922                            for (JournalArticle journalArticle : list) {
23923                                    if ((groupId != journalArticle.getGroupId()) ||
23924                                                    (classNameId != journalArticle.getClassNameId()) ||
23925                                                    !Validator.equals(layoutUuid,
23926                                                            journalArticle.getLayoutUuid())) {
23927                                            list = null;
23928    
23929                                            break;
23930                                    }
23931                            }
23932                    }
23933    
23934                    if (list == null) {
23935                            StringBundler query = null;
23936    
23937                            if (orderByComparator != null) {
23938                                    query = new StringBundler(5 +
23939                                                    (orderByComparator.getOrderByFields().length * 3));
23940                            }
23941                            else {
23942                                    query = new StringBundler(5);
23943                            }
23944    
23945                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
23946    
23947                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
23948    
23949                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
23950    
23951                            boolean bindLayoutUuid = false;
23952    
23953                            if (layoutUuid == null) {
23954                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
23955                            }
23956                            else if (layoutUuid.equals(StringPool.BLANK)) {
23957                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
23958                            }
23959                            else {
23960                                    bindLayoutUuid = true;
23961    
23962                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
23963                            }
23964    
23965                            if (orderByComparator != null) {
23966                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
23967                                            orderByComparator);
23968                            }
23969                            else
23970                             if (pagination) {
23971                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23972                            }
23973    
23974                            String sql = query.toString();
23975    
23976                            Session session = null;
23977    
23978                            try {
23979                                    session = openSession();
23980    
23981                                    Query q = session.createQuery(sql);
23982    
23983                                    QueryPos qPos = QueryPos.getInstance(q);
23984    
23985                                    qPos.add(groupId);
23986    
23987                                    qPos.add(classNameId);
23988    
23989                                    if (bindLayoutUuid) {
23990                                            qPos.add(layoutUuid);
23991                                    }
23992    
23993                                    if (!pagination) {
23994                                            list = (List<JournalArticle>)QueryUtil.list(q,
23995                                                            getDialect(), start, end, false);
23996    
23997                                            Collections.sort(list);
23998    
23999                                            list = new UnmodifiableList<JournalArticle>(list);
24000                                    }
24001                                    else {
24002                                            list = (List<JournalArticle>)QueryUtil.list(q,
24003                                                            getDialect(), start, end);
24004                                    }
24005    
24006                                    cacheResult(list);
24007    
24008                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
24009                            }
24010                            catch (Exception e) {
24011                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
24012    
24013                                    throw processException(e);
24014                            }
24015                            finally {
24016                                    closeSession(session);
24017                            }
24018                    }
24019    
24020                    return list;
24021            }
24022    
24023            /**
24024             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
24025             *
24026             * @param groupId the group ID
24027             * @param classNameId the class name ID
24028             * @param layoutUuid the layout uuid
24029             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24030             * @return the first matching journal article
24031             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
24032             * @throws SystemException if a system exception occurred
24033             */
24034            @Override
24035            public JournalArticle findByG_C_L_First(long groupId, long classNameId,
24036                    String layoutUuid, OrderByComparator orderByComparator)
24037                    throws NoSuchArticleException, SystemException {
24038                    JournalArticle journalArticle = fetchByG_C_L_First(groupId,
24039                                    classNameId, layoutUuid, orderByComparator);
24040    
24041                    if (journalArticle != null) {
24042                            return journalArticle;
24043                    }
24044    
24045                    StringBundler msg = new StringBundler(8);
24046    
24047                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
24048    
24049                    msg.append("groupId=");
24050                    msg.append(groupId);
24051    
24052                    msg.append(", classNameId=");
24053                    msg.append(classNameId);
24054    
24055                    msg.append(", layoutUuid=");
24056                    msg.append(layoutUuid);
24057    
24058                    msg.append(StringPool.CLOSE_CURLY_BRACE);
24059    
24060                    throw new NoSuchArticleException(msg.toString());
24061            }
24062    
24063            /**
24064             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
24065             *
24066             * @param groupId the group ID
24067             * @param classNameId the class name ID
24068             * @param layoutUuid the layout uuid
24069             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24070             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
24071             * @throws SystemException if a system exception occurred
24072             */
24073            @Override
24074            public JournalArticle fetchByG_C_L_First(long groupId, long classNameId,
24075                    String layoutUuid, OrderByComparator orderByComparator)
24076                    throws SystemException {
24077                    List<JournalArticle> list = findByG_C_L(groupId, classNameId,
24078                                    layoutUuid, 0, 1, orderByComparator);
24079    
24080                    if (!list.isEmpty()) {
24081                            return list.get(0);
24082                    }
24083    
24084                    return null;
24085            }
24086    
24087            /**
24088             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
24089             *
24090             * @param groupId the group ID
24091             * @param classNameId the class name ID
24092             * @param layoutUuid the layout uuid
24093             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24094             * @return the last matching journal article
24095             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
24096             * @throws SystemException if a system exception occurred
24097             */
24098            @Override
24099            public JournalArticle findByG_C_L_Last(long groupId, long classNameId,
24100                    String layoutUuid, OrderByComparator orderByComparator)
24101                    throws NoSuchArticleException, SystemException {
24102                    JournalArticle journalArticle = fetchByG_C_L_Last(groupId, classNameId,
24103                                    layoutUuid, orderByComparator);
24104    
24105                    if (journalArticle != null) {
24106                            return journalArticle;
24107                    }
24108    
24109                    StringBundler msg = new StringBundler(8);
24110    
24111                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
24112    
24113                    msg.append("groupId=");
24114                    msg.append(groupId);
24115    
24116                    msg.append(", classNameId=");
24117                    msg.append(classNameId);
24118    
24119                    msg.append(", layoutUuid=");
24120                    msg.append(layoutUuid);
24121    
24122                    msg.append(StringPool.CLOSE_CURLY_BRACE);
24123    
24124                    throw new NoSuchArticleException(msg.toString());
24125            }
24126    
24127            /**
24128             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
24129             *
24130             * @param groupId the group ID
24131             * @param classNameId the class name ID
24132             * @param layoutUuid the layout uuid
24133             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24134             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
24135             * @throws SystemException if a system exception occurred
24136             */
24137            @Override
24138            public JournalArticle fetchByG_C_L_Last(long groupId, long classNameId,
24139                    String layoutUuid, OrderByComparator orderByComparator)
24140                    throws SystemException {
24141                    int count = countByG_C_L(groupId, classNameId, layoutUuid);
24142    
24143                    if (count == 0) {
24144                            return null;
24145                    }
24146    
24147                    List<JournalArticle> list = findByG_C_L(groupId, classNameId,
24148                                    layoutUuid, count - 1, count, orderByComparator);
24149    
24150                    if (!list.isEmpty()) {
24151                            return list.get(0);
24152                    }
24153    
24154                    return null;
24155            }
24156    
24157            /**
24158             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
24159             *
24160             * @param id the primary key of the current journal article
24161             * @param groupId the group ID
24162             * @param classNameId the class name ID
24163             * @param layoutUuid the layout uuid
24164             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24165             * @return the previous, current, and next journal article
24166             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
24167             * @throws SystemException if a system exception occurred
24168             */
24169            @Override
24170            public JournalArticle[] findByG_C_L_PrevAndNext(long id, long groupId,
24171                    long classNameId, String layoutUuid, OrderByComparator orderByComparator)
24172                    throws NoSuchArticleException, SystemException {
24173                    JournalArticle journalArticle = findByPrimaryKey(id);
24174    
24175                    Session session = null;
24176    
24177                    try {
24178                            session = openSession();
24179    
24180                            JournalArticle[] array = new JournalArticleImpl[3];
24181    
24182                            array[0] = getByG_C_L_PrevAndNext(session, journalArticle, groupId,
24183                                            classNameId, layoutUuid, orderByComparator, true);
24184    
24185                            array[1] = journalArticle;
24186    
24187                            array[2] = getByG_C_L_PrevAndNext(session, journalArticle, groupId,
24188                                            classNameId, layoutUuid, orderByComparator, false);
24189    
24190                            return array;
24191                    }
24192                    catch (Exception e) {
24193                            throw processException(e);
24194                    }
24195                    finally {
24196                            closeSession(session);
24197                    }
24198            }
24199    
24200            protected JournalArticle getByG_C_L_PrevAndNext(Session session,
24201                    JournalArticle journalArticle, long groupId, long classNameId,
24202                    String layoutUuid, OrderByComparator orderByComparator, boolean previous) {
24203                    StringBundler query = null;
24204    
24205                    if (orderByComparator != null) {
24206                            query = new StringBundler(6 +
24207                                            (orderByComparator.getOrderByFields().length * 6));
24208                    }
24209                    else {
24210                            query = new StringBundler(3);
24211                    }
24212    
24213                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
24214    
24215                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
24216    
24217                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
24218    
24219                    boolean bindLayoutUuid = false;
24220    
24221                    if (layoutUuid == null) {
24222                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
24223                    }
24224                    else if (layoutUuid.equals(StringPool.BLANK)) {
24225                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
24226                    }
24227                    else {
24228                            bindLayoutUuid = true;
24229    
24230                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
24231                    }
24232    
24233                    if (orderByComparator != null) {
24234                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
24235    
24236                            if (orderByConditionFields.length > 0) {
24237                                    query.append(WHERE_AND);
24238                            }
24239    
24240                            for (int i = 0; i < orderByConditionFields.length; i++) {
24241                                    query.append(_ORDER_BY_ENTITY_ALIAS);
24242                                    query.append(orderByConditionFields[i]);
24243    
24244                                    if ((i + 1) < orderByConditionFields.length) {
24245                                            if (orderByComparator.isAscending() ^ previous) {
24246                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
24247                                            }
24248                                            else {
24249                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
24250                                            }
24251                                    }
24252                                    else {
24253                                            if (orderByComparator.isAscending() ^ previous) {
24254                                                    query.append(WHERE_GREATER_THAN);
24255                                            }
24256                                            else {
24257                                                    query.append(WHERE_LESSER_THAN);
24258                                            }
24259                                    }
24260                            }
24261    
24262                            query.append(ORDER_BY_CLAUSE);
24263    
24264                            String[] orderByFields = orderByComparator.getOrderByFields();
24265    
24266                            for (int i = 0; i < orderByFields.length; i++) {
24267                                    query.append(_ORDER_BY_ENTITY_ALIAS);
24268                                    query.append(orderByFields[i]);
24269    
24270                                    if ((i + 1) < orderByFields.length) {
24271                                            if (orderByComparator.isAscending() ^ previous) {
24272                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
24273                                            }
24274                                            else {
24275                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
24276                                            }
24277                                    }
24278                                    else {
24279                                            if (orderByComparator.isAscending() ^ previous) {
24280                                                    query.append(ORDER_BY_ASC);
24281                                            }
24282                                            else {
24283                                                    query.append(ORDER_BY_DESC);
24284                                            }
24285                                    }
24286                            }
24287                    }
24288                    else {
24289                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
24290                    }
24291    
24292                    String sql = query.toString();
24293    
24294                    Query q = session.createQuery(sql);
24295    
24296                    q.setFirstResult(0);
24297                    q.setMaxResults(2);
24298    
24299                    QueryPos qPos = QueryPos.getInstance(q);
24300    
24301                    qPos.add(groupId);
24302    
24303                    qPos.add(classNameId);
24304    
24305                    if (bindLayoutUuid) {
24306                            qPos.add(layoutUuid);
24307                    }
24308    
24309                    if (orderByComparator != null) {
24310                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
24311    
24312                            for (Object value : values) {
24313                                    qPos.add(value);
24314                            }
24315                    }
24316    
24317                    List<JournalArticle> list = q.list();
24318    
24319                    if (list.size() == 2) {
24320                            return list.get(1);
24321                    }
24322                    else {
24323                            return null;
24324                    }
24325            }
24326    
24327            /**
24328             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
24329             *
24330             * @param groupId the group ID
24331             * @param classNameId the class name ID
24332             * @param layoutUuid the layout uuid
24333             * @return the matching journal articles that the user has permission to view
24334             * @throws SystemException if a system exception occurred
24335             */
24336            @Override
24337            public List<JournalArticle> filterFindByG_C_L(long groupId,
24338                    long classNameId, String layoutUuid) throws SystemException {
24339                    return filterFindByG_C_L(groupId, classNameId, layoutUuid,
24340                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
24341            }
24342    
24343            /**
24344             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
24345             *
24346             * <p>
24347             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
24348             * </p>
24349             *
24350             * @param groupId the group ID
24351             * @param classNameId the class name ID
24352             * @param layoutUuid the layout uuid
24353             * @param start the lower bound of the range of journal articles
24354             * @param end the upper bound of the range of journal articles (not inclusive)
24355             * @return the range of matching journal articles that the user has permission to view
24356             * @throws SystemException if a system exception occurred
24357             */
24358            @Override
24359            public List<JournalArticle> filterFindByG_C_L(long groupId,
24360                    long classNameId, String layoutUuid, int start, int end)
24361                    throws SystemException {
24362                    return filterFindByG_C_L(groupId, classNameId, layoutUuid, start, end,
24363                            null);
24364            }
24365    
24366            /**
24367             * 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;.
24368             *
24369             * <p>
24370             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
24371             * </p>
24372             *
24373             * @param groupId the group ID
24374             * @param classNameId the class name ID
24375             * @param layoutUuid the layout uuid
24376             * @param start the lower bound of the range of journal articles
24377             * @param end the upper bound of the range of journal articles (not inclusive)
24378             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
24379             * @return the ordered range of matching journal articles that the user has permission to view
24380             * @throws SystemException if a system exception occurred
24381             */
24382            @Override
24383            public List<JournalArticle> filterFindByG_C_L(long groupId,
24384                    long classNameId, String layoutUuid, int start, int end,
24385                    OrderByComparator orderByComparator) throws SystemException {
24386                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
24387                            return findByG_C_L(groupId, classNameId, layoutUuid, start, end,
24388                                    orderByComparator);
24389                    }
24390    
24391                    StringBundler query = null;
24392    
24393                    if (orderByComparator != null) {
24394                            query = new StringBundler(5 +
24395                                            (orderByComparator.getOrderByFields().length * 3));
24396                    }
24397                    else {
24398                            query = new StringBundler(5);
24399                    }
24400    
24401                    if (getDB().isSupportsInlineDistinct()) {
24402                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
24403                    }
24404                    else {
24405                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
24406                    }
24407    
24408                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
24409    
24410                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
24411    
24412                    boolean bindLayoutUuid = false;
24413    
24414                    if (layoutUuid == null) {
24415                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
24416                    }
24417                    else if (layoutUuid.equals(StringPool.BLANK)) {
24418                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
24419                    }
24420                    else {
24421                            bindLayoutUuid = true;
24422    
24423                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
24424                    }
24425    
24426                    if (!getDB().isSupportsInlineDistinct()) {
24427                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
24428                    }
24429    
24430                    if (orderByComparator != null) {
24431                            if (getDB().isSupportsInlineDistinct()) {
24432                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
24433                                            orderByComparator, true);
24434                            }
24435                            else {
24436                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
24437                                            orderByComparator, true);
24438                            }
24439                    }
24440                    else {
24441                            if (getDB().isSupportsInlineDistinct()) {
24442                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
24443                            }
24444                            else {
24445                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
24446                            }
24447                    }
24448    
24449                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
24450                                    JournalArticle.class.getName(),
24451                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
24452    
24453                    Session session = null;
24454    
24455                    try {
24456                            session = openSession();
24457    
24458                            SQLQuery q = session.createSQLQuery(sql);
24459    
24460                            if (getDB().isSupportsInlineDistinct()) {
24461                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
24462                            }
24463                            else {
24464                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
24465                            }
24466    
24467                            QueryPos qPos = QueryPos.getInstance(q);
24468    
24469                            qPos.add(groupId);
24470    
24471                            qPos.add(classNameId);
24472    
24473                            if (bindLayoutUuid) {
24474                                    qPos.add(layoutUuid);
24475                            }
24476    
24477                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
24478                                    end);
24479                    }
24480                    catch (Exception e) {
24481                            throw processException(e);
24482                    }
24483                    finally {
24484                            closeSession(session);
24485                    }
24486            }
24487    
24488            /**
24489             * 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;.
24490             *
24491             * @param id the primary key of the current journal article
24492             * @param groupId the group ID
24493             * @param classNameId the class name ID
24494             * @param layoutUuid the layout uuid
24495             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24496             * @return the previous, current, and next journal article
24497             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
24498             * @throws SystemException if a system exception occurred
24499             */
24500            @Override
24501            public JournalArticle[] filterFindByG_C_L_PrevAndNext(long id,
24502                    long groupId, long classNameId, String layoutUuid,
24503                    OrderByComparator orderByComparator)
24504                    throws NoSuchArticleException, SystemException {
24505                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
24506                            return findByG_C_L_PrevAndNext(id, groupId, classNameId,
24507                                    layoutUuid, orderByComparator);
24508                    }
24509    
24510                    JournalArticle journalArticle = findByPrimaryKey(id);
24511    
24512                    Session session = null;
24513    
24514                    try {
24515                            session = openSession();
24516    
24517                            JournalArticle[] array = new JournalArticleImpl[3];
24518    
24519                            array[0] = filterGetByG_C_L_PrevAndNext(session, journalArticle,
24520                                            groupId, classNameId, layoutUuid, orderByComparator, true);
24521    
24522                            array[1] = journalArticle;
24523    
24524                            array[2] = filterGetByG_C_L_PrevAndNext(session, journalArticle,
24525                                            groupId, classNameId, layoutUuid, orderByComparator, false);
24526    
24527                            return array;
24528                    }
24529                    catch (Exception e) {
24530                            throw processException(e);
24531                    }
24532                    finally {
24533                            closeSession(session);
24534                    }
24535            }
24536    
24537            protected JournalArticle filterGetByG_C_L_PrevAndNext(Session session,
24538                    JournalArticle journalArticle, long groupId, long classNameId,
24539                    String layoutUuid, OrderByComparator orderByComparator, boolean previous) {
24540                    StringBundler query = null;
24541    
24542                    if (orderByComparator != null) {
24543                            query = new StringBundler(6 +
24544                                            (orderByComparator.getOrderByFields().length * 6));
24545                    }
24546                    else {
24547                            query = new StringBundler(3);
24548                    }
24549    
24550                    if (getDB().isSupportsInlineDistinct()) {
24551                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
24552                    }
24553                    else {
24554                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
24555                    }
24556    
24557                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
24558    
24559                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
24560    
24561                    boolean bindLayoutUuid = false;
24562    
24563                    if (layoutUuid == null) {
24564                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
24565                    }
24566                    else if (layoutUuid.equals(StringPool.BLANK)) {
24567                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
24568                    }
24569                    else {
24570                            bindLayoutUuid = true;
24571    
24572                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
24573                    }
24574    
24575                    if (!getDB().isSupportsInlineDistinct()) {
24576                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
24577                    }
24578    
24579                    if (orderByComparator != null) {
24580                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
24581    
24582                            if (orderByConditionFields.length > 0) {
24583                                    query.append(WHERE_AND);
24584                            }
24585    
24586                            for (int i = 0; i < orderByConditionFields.length; i++) {
24587                                    if (getDB().isSupportsInlineDistinct()) {
24588                                            query.append(_ORDER_BY_ENTITY_ALIAS);
24589                                    }
24590                                    else {
24591                                            query.append(_ORDER_BY_ENTITY_TABLE);
24592                                    }
24593    
24594                                    query.append(orderByConditionFields[i]);
24595    
24596                                    if ((i + 1) < orderByConditionFields.length) {
24597                                            if (orderByComparator.isAscending() ^ previous) {
24598                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
24599                                            }
24600                                            else {
24601                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
24602                                            }
24603                                    }
24604                                    else {
24605                                            if (orderByComparator.isAscending() ^ previous) {
24606                                                    query.append(WHERE_GREATER_THAN);
24607                                            }
24608                                            else {
24609                                                    query.append(WHERE_LESSER_THAN);
24610                                            }
24611                                    }
24612                            }
24613    
24614                            query.append(ORDER_BY_CLAUSE);
24615    
24616                            String[] orderByFields = orderByComparator.getOrderByFields();
24617    
24618                            for (int i = 0; i < orderByFields.length; i++) {
24619                                    if (getDB().isSupportsInlineDistinct()) {
24620                                            query.append(_ORDER_BY_ENTITY_ALIAS);
24621                                    }
24622                                    else {
24623                                            query.append(_ORDER_BY_ENTITY_TABLE);
24624                                    }
24625    
24626                                    query.append(orderByFields[i]);
24627    
24628                                    if ((i + 1) < orderByFields.length) {
24629                                            if (orderByComparator.isAscending() ^ previous) {
24630                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
24631                                            }
24632                                            else {
24633                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
24634                                            }
24635                                    }
24636                                    else {
24637                                            if (orderByComparator.isAscending() ^ previous) {
24638                                                    query.append(ORDER_BY_ASC);
24639                                            }
24640                                            else {
24641                                                    query.append(ORDER_BY_DESC);
24642                                            }
24643                                    }
24644                            }
24645                    }
24646                    else {
24647                            if (getDB().isSupportsInlineDistinct()) {
24648                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
24649                            }
24650                            else {
24651                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
24652                            }
24653                    }
24654    
24655                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
24656                                    JournalArticle.class.getName(),
24657                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
24658    
24659                    SQLQuery q = session.createSQLQuery(sql);
24660    
24661                    q.setFirstResult(0);
24662                    q.setMaxResults(2);
24663    
24664                    if (getDB().isSupportsInlineDistinct()) {
24665                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
24666                    }
24667                    else {
24668                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
24669                    }
24670    
24671                    QueryPos qPos = QueryPos.getInstance(q);
24672    
24673                    qPos.add(groupId);
24674    
24675                    qPos.add(classNameId);
24676    
24677                    if (bindLayoutUuid) {
24678                            qPos.add(layoutUuid);
24679                    }
24680    
24681                    if (orderByComparator != null) {
24682                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
24683    
24684                            for (Object value : values) {
24685                                    qPos.add(value);
24686                            }
24687                    }
24688    
24689                    List<JournalArticle> list = q.list();
24690    
24691                    if (list.size() == 2) {
24692                            return list.get(1);
24693                    }
24694                    else {
24695                            return null;
24696                    }
24697            }
24698    
24699            /**
24700             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63; from the database.
24701             *
24702             * @param groupId the group ID
24703             * @param classNameId the class name ID
24704             * @param layoutUuid the layout uuid
24705             * @throws SystemException if a system exception occurred
24706             */
24707            @Override
24708            public void removeByG_C_L(long groupId, long classNameId, String layoutUuid)
24709                    throws SystemException {
24710                    for (JournalArticle journalArticle : findByG_C_L(groupId, classNameId,
24711                                    layoutUuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
24712                            remove(journalArticle);
24713                    }
24714            }
24715    
24716            /**
24717             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
24718             *
24719             * @param groupId the group ID
24720             * @param classNameId the class name ID
24721             * @param layoutUuid the layout uuid
24722             * @return the number of matching journal articles
24723             * @throws SystemException if a system exception occurred
24724             */
24725            @Override
24726            public int countByG_C_L(long groupId, long classNameId, String layoutUuid)
24727                    throws SystemException {
24728                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_L;
24729    
24730                    Object[] finderArgs = new Object[] { groupId, classNameId, layoutUuid };
24731    
24732                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
24733                                    this);
24734    
24735                    if (count == null) {
24736                            StringBundler query = new StringBundler(4);
24737    
24738                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
24739    
24740                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
24741    
24742                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
24743    
24744                            boolean bindLayoutUuid = false;
24745    
24746                            if (layoutUuid == null) {
24747                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
24748                            }
24749                            else if (layoutUuid.equals(StringPool.BLANK)) {
24750                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
24751                            }
24752                            else {
24753                                    bindLayoutUuid = true;
24754    
24755                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
24756                            }
24757    
24758                            String sql = query.toString();
24759    
24760                            Session session = null;
24761    
24762                            try {
24763                                    session = openSession();
24764    
24765                                    Query q = session.createQuery(sql);
24766    
24767                                    QueryPos qPos = QueryPos.getInstance(q);
24768    
24769                                    qPos.add(groupId);
24770    
24771                                    qPos.add(classNameId);
24772    
24773                                    if (bindLayoutUuid) {
24774                                            qPos.add(layoutUuid);
24775                                    }
24776    
24777                                    count = (Long)q.uniqueResult();
24778    
24779                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
24780                            }
24781                            catch (Exception e) {
24782                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
24783    
24784                                    throw processException(e);
24785                            }
24786                            finally {
24787                                    closeSession(session);
24788                            }
24789                    }
24790    
24791                    return count.intValue();
24792            }
24793    
24794            /**
24795             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
24796             *
24797             * @param groupId the group ID
24798             * @param classNameId the class name ID
24799             * @param layoutUuid the layout uuid
24800             * @return the number of matching journal articles that the user has permission to view
24801             * @throws SystemException if a system exception occurred
24802             */
24803            @Override
24804            public int filterCountByG_C_L(long groupId, long classNameId,
24805                    String layoutUuid) throws SystemException {
24806                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
24807                            return countByG_C_L(groupId, classNameId, layoutUuid);
24808                    }
24809    
24810                    StringBundler query = new StringBundler(4);
24811    
24812                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
24813    
24814                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
24815    
24816                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
24817    
24818                    boolean bindLayoutUuid = false;
24819    
24820                    if (layoutUuid == null) {
24821                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
24822                    }
24823                    else if (layoutUuid.equals(StringPool.BLANK)) {
24824                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
24825                    }
24826                    else {
24827                            bindLayoutUuid = true;
24828    
24829                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
24830                    }
24831    
24832                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
24833                                    JournalArticle.class.getName(),
24834                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
24835    
24836                    Session session = null;
24837    
24838                    try {
24839                            session = openSession();
24840    
24841                            SQLQuery q = session.createSQLQuery(sql);
24842    
24843                            q.addScalar(COUNT_COLUMN_NAME,
24844                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
24845    
24846                            QueryPos qPos = QueryPos.getInstance(q);
24847    
24848                            qPos.add(groupId);
24849    
24850                            qPos.add(classNameId);
24851    
24852                            if (bindLayoutUuid) {
24853                                    qPos.add(layoutUuid);
24854                            }
24855    
24856                            Long count = (Long)q.uniqueResult();
24857    
24858                            return count.intValue();
24859                    }
24860                    catch (Exception e) {
24861                            throw processException(e);
24862                    }
24863                    finally {
24864                            closeSession(session);
24865                    }
24866            }
24867    
24868            private static final String _FINDER_COLUMN_G_C_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
24869            private static final String _FINDER_COLUMN_G_C_L_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
24870            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
24871            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
24872            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = '')";
24873            public static final FinderPath FINDER_PATH_FETCH_BY_G_A_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24874                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
24875                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_A_V",
24876                            new String[] {
24877                                    Long.class.getName(), String.class.getName(),
24878                                    Double.class.getName()
24879                            },
24880                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
24881                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
24882                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
24883            public static final FinderPath FINDER_PATH_COUNT_BY_G_A_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24884                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
24885                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A_V",
24886                            new String[] {
24887                                    Long.class.getName(), String.class.getName(),
24888                                    Double.class.getName()
24889                            });
24890    
24891            /**
24892             * 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.
24893             *
24894             * @param groupId the group ID
24895             * @param articleId the article ID
24896             * @param version the version
24897             * @return the matching journal article
24898             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
24899             * @throws SystemException if a system exception occurred
24900             */
24901            @Override
24902            public JournalArticle findByG_A_V(long groupId, String articleId,
24903                    double version) throws NoSuchArticleException, SystemException {
24904                    JournalArticle journalArticle = fetchByG_A_V(groupId, articleId, version);
24905    
24906                    if (journalArticle == null) {
24907                            StringBundler msg = new StringBundler(8);
24908    
24909                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
24910    
24911                            msg.append("groupId=");
24912                            msg.append(groupId);
24913    
24914                            msg.append(", articleId=");
24915                            msg.append(articleId);
24916    
24917                            msg.append(", version=");
24918                            msg.append(version);
24919    
24920                            msg.append(StringPool.CLOSE_CURLY_BRACE);
24921    
24922                            if (_log.isWarnEnabled()) {
24923                                    _log.warn(msg.toString());
24924                            }
24925    
24926                            throw new NoSuchArticleException(msg.toString());
24927                    }
24928    
24929                    return journalArticle;
24930            }
24931    
24932            /**
24933             * 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.
24934             *
24935             * @param groupId the group ID
24936             * @param articleId the article ID
24937             * @param version the version
24938             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
24939             * @throws SystemException if a system exception occurred
24940             */
24941            @Override
24942            public JournalArticle fetchByG_A_V(long groupId, String articleId,
24943                    double version) throws SystemException {
24944                    return fetchByG_A_V(groupId, articleId, version, true);
24945            }
24946    
24947            /**
24948             * 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.
24949             *
24950             * @param groupId the group ID
24951             * @param articleId the article ID
24952             * @param version the version
24953             * @param retrieveFromCache whether to use the finder cache
24954             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
24955             * @throws SystemException if a system exception occurred
24956             */
24957            @Override
24958            public JournalArticle fetchByG_A_V(long groupId, String articleId,
24959                    double version, boolean retrieveFromCache) throws SystemException {
24960                    Object[] finderArgs = new Object[] { groupId, articleId, version };
24961    
24962                    Object result = null;
24963    
24964                    if (retrieveFromCache) {
24965                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_A_V,
24966                                            finderArgs, this);
24967                    }
24968    
24969                    if (result instanceof JournalArticle) {
24970                            JournalArticle journalArticle = (JournalArticle)result;
24971    
24972                            if ((groupId != journalArticle.getGroupId()) ||
24973                                            !Validator.equals(articleId, journalArticle.getArticleId()) ||
24974                                            (version != journalArticle.getVersion())) {
24975                                    result = null;
24976                            }
24977                    }
24978    
24979                    if (result == null) {
24980                            StringBundler query = new StringBundler(5);
24981    
24982                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
24983    
24984                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
24985    
24986                            boolean bindArticleId = false;
24987    
24988                            if (articleId == null) {
24989                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
24990                            }
24991                            else if (articleId.equals(StringPool.BLANK)) {
24992                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
24993                            }
24994                            else {
24995                                    bindArticleId = true;
24996    
24997                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
24998                            }
24999    
25000                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
25001    
25002                            String sql = query.toString();
25003    
25004                            Session session = null;
25005    
25006                            try {
25007                                    session = openSession();
25008    
25009                                    Query q = session.createQuery(sql);
25010    
25011                                    QueryPos qPos = QueryPos.getInstance(q);
25012    
25013                                    qPos.add(groupId);
25014    
25015                                    if (bindArticleId) {
25016                                            qPos.add(articleId);
25017                                    }
25018    
25019                                    qPos.add(version);
25020    
25021                                    List<JournalArticle> list = q.list();
25022    
25023                                    if (list.isEmpty()) {
25024                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
25025                                                    finderArgs, list);
25026                                    }
25027                                    else {
25028                                            JournalArticle journalArticle = list.get(0);
25029    
25030                                            result = journalArticle;
25031    
25032                                            cacheResult(journalArticle);
25033    
25034                                            if ((journalArticle.getGroupId() != groupId) ||
25035                                                            (journalArticle.getArticleId() == null) ||
25036                                                            !journalArticle.getArticleId().equals(articleId) ||
25037                                                            (journalArticle.getVersion() != version)) {
25038                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
25039                                                            finderArgs, journalArticle);
25040                                            }
25041                                    }
25042                            }
25043                            catch (Exception e) {
25044                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V,
25045                                            finderArgs);
25046    
25047                                    throw processException(e);
25048                            }
25049                            finally {
25050                                    closeSession(session);
25051                            }
25052                    }
25053    
25054                    if (result instanceof List<?>) {
25055                            return null;
25056                    }
25057                    else {
25058                            return (JournalArticle)result;
25059                    }
25060            }
25061    
25062            /**
25063             * Removes the journal article where groupId = &#63; and articleId = &#63; and version = &#63; from the database.
25064             *
25065             * @param groupId the group ID
25066             * @param articleId the article ID
25067             * @param version the version
25068             * @return the journal article that was removed
25069             * @throws SystemException if a system exception occurred
25070             */
25071            @Override
25072            public JournalArticle removeByG_A_V(long groupId, String articleId,
25073                    double version) throws NoSuchArticleException, SystemException {
25074                    JournalArticle journalArticle = findByG_A_V(groupId, articleId, version);
25075    
25076                    return remove(journalArticle);
25077            }
25078    
25079            /**
25080             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and version = &#63;.
25081             *
25082             * @param groupId the group ID
25083             * @param articleId the article ID
25084             * @param version the version
25085             * @return the number of matching journal articles
25086             * @throws SystemException if a system exception occurred
25087             */
25088            @Override
25089            public int countByG_A_V(long groupId, String articleId, double version)
25090                    throws SystemException {
25091                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A_V;
25092    
25093                    Object[] finderArgs = new Object[] { groupId, articleId, version };
25094    
25095                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
25096                                    this);
25097    
25098                    if (count == null) {
25099                            StringBundler query = new StringBundler(4);
25100    
25101                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
25102    
25103                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
25104    
25105                            boolean bindArticleId = false;
25106    
25107                            if (articleId == null) {
25108                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
25109                            }
25110                            else if (articleId.equals(StringPool.BLANK)) {
25111                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
25112                            }
25113                            else {
25114                                    bindArticleId = true;
25115    
25116                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
25117                            }
25118    
25119                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
25120    
25121                            String sql = query.toString();
25122    
25123                            Session session = null;
25124    
25125                            try {
25126                                    session = openSession();
25127    
25128                                    Query q = session.createQuery(sql);
25129    
25130                                    QueryPos qPos = QueryPos.getInstance(q);
25131    
25132                                    qPos.add(groupId);
25133    
25134                                    if (bindArticleId) {
25135                                            qPos.add(articleId);
25136                                    }
25137    
25138                                    qPos.add(version);
25139    
25140                                    count = (Long)q.uniqueResult();
25141    
25142                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
25143                            }
25144                            catch (Exception e) {
25145                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
25146    
25147                                    throw processException(e);
25148                            }
25149                            finally {
25150                                    closeSession(session);
25151                            }
25152                    }
25153    
25154                    return count.intValue();
25155            }
25156    
25157            private static final String _FINDER_COLUMN_G_A_V_GROUPID_2 = "journalArticle.groupId = ? AND ";
25158            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
25159            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
25160            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '') AND ";
25161            private static final String _FINDER_COLUMN_G_A_V_VERSION_2 = "journalArticle.version = ?";
25162            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
25163                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
25164                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
25165                            "findByG_A_ST",
25166                            new String[] {
25167                                    Long.class.getName(), String.class.getName(),
25168                                    Integer.class.getName(),
25169                                    
25170                            Integer.class.getName(), Integer.class.getName(),
25171                                    OrderByComparator.class.getName()
25172                            });
25173            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST =
25174                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
25175                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
25176                            JournalArticleImpl.class,
25177                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A_ST",
25178                            new String[] {
25179                                    Long.class.getName(), String.class.getName(),
25180                                    Integer.class.getName()
25181                            },
25182                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
25183                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
25184                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
25185                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
25186            public static final FinderPath FINDER_PATH_COUNT_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
25187                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
25188                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A_ST",
25189                            new String[] {
25190                                    Long.class.getName(), String.class.getName(),
25191                                    Integer.class.getName()
25192                            });
25193            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
25194                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
25195                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_A_ST",
25196                            new String[] {
25197                                    Long.class.getName(), String.class.getName(),
25198                                    Integer.class.getName()
25199                            });
25200    
25201            /**
25202             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
25203             *
25204             * @param groupId the group ID
25205             * @param articleId the article ID
25206             * @param status the status
25207             * @return the matching journal articles
25208             * @throws SystemException if a system exception occurred
25209             */
25210            @Override
25211            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
25212                    int status) throws SystemException {
25213                    return findByG_A_ST(groupId, articleId, status, QueryUtil.ALL_POS,
25214                            QueryUtil.ALL_POS, null);
25215            }
25216    
25217            /**
25218             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
25219             *
25220             * <p>
25221             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
25222             * </p>
25223             *
25224             * @param groupId the group ID
25225             * @param articleId the article ID
25226             * @param status the status
25227             * @param start the lower bound of the range of journal articles
25228             * @param end the upper bound of the range of journal articles (not inclusive)
25229             * @return the range of matching journal articles
25230             * @throws SystemException if a system exception occurred
25231             */
25232            @Override
25233            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
25234                    int status, int start, int end) throws SystemException {
25235                    return findByG_A_ST(groupId, articleId, status, start, end, null);
25236            }
25237    
25238            /**
25239             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
25240             *
25241             * <p>
25242             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
25243             * </p>
25244             *
25245             * @param groupId the group ID
25246             * @param articleId the article ID
25247             * @param status the status
25248             * @param start the lower bound of the range of journal articles
25249             * @param end the upper bound of the range of journal articles (not inclusive)
25250             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
25251             * @return the ordered range of matching journal articles
25252             * @throws SystemException if a system exception occurred
25253             */
25254            @Override
25255            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
25256                    int status, int start, int end, OrderByComparator orderByComparator)
25257                    throws SystemException {
25258                    boolean pagination = true;
25259                    FinderPath finderPath = null;
25260                    Object[] finderArgs = null;
25261    
25262                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
25263                                    (orderByComparator == null)) {
25264                            pagination = false;
25265                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST;
25266                            finderArgs = new Object[] { groupId, articleId, status };
25267                    }
25268                    else {
25269                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST;
25270                            finderArgs = new Object[] {
25271                                            groupId, articleId, status,
25272                                            
25273                                            start, end, orderByComparator
25274                                    };
25275                    }
25276    
25277                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
25278                                    finderArgs, this);
25279    
25280                    if ((list != null) && !list.isEmpty()) {
25281                            for (JournalArticle journalArticle : list) {
25282                                    if ((groupId != journalArticle.getGroupId()) ||
25283                                                    !Validator.equals(articleId,
25284                                                            journalArticle.getArticleId()) ||
25285                                                    (status != journalArticle.getStatus())) {
25286                                            list = null;
25287    
25288                                            break;
25289                                    }
25290                            }
25291                    }
25292    
25293                    if (list == null) {
25294                            StringBundler query = null;
25295    
25296                            if (orderByComparator != null) {
25297                                    query = new StringBundler(5 +
25298                                                    (orderByComparator.getOrderByFields().length * 3));
25299                            }
25300                            else {
25301                                    query = new StringBundler(5);
25302                            }
25303    
25304                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
25305    
25306                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
25307    
25308                            boolean bindArticleId = false;
25309    
25310                            if (articleId == null) {
25311                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
25312                            }
25313                            else if (articleId.equals(StringPool.BLANK)) {
25314                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
25315                            }
25316                            else {
25317                                    bindArticleId = true;
25318    
25319                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
25320                            }
25321    
25322                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
25323    
25324                            if (orderByComparator != null) {
25325                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
25326                                            orderByComparator);
25327                            }
25328                            else
25329                             if (pagination) {
25330                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
25331                            }
25332    
25333                            String sql = query.toString();
25334    
25335                            Session session = null;
25336    
25337                            try {
25338                                    session = openSession();
25339    
25340                                    Query q = session.createQuery(sql);
25341    
25342                                    QueryPos qPos = QueryPos.getInstance(q);
25343    
25344                                    qPos.add(groupId);
25345    
25346                                    if (bindArticleId) {
25347                                            qPos.add(articleId);
25348                                    }
25349    
25350                                    qPos.add(status);
25351    
25352                                    if (!pagination) {
25353                                            list = (List<JournalArticle>)QueryUtil.list(q,
25354                                                            getDialect(), start, end, false);
25355    
25356                                            Collections.sort(list);
25357    
25358                                            list = new UnmodifiableList<JournalArticle>(list);
25359                                    }
25360                                    else {
25361                                            list = (List<JournalArticle>)QueryUtil.list(q,
25362                                                            getDialect(), start, end);
25363                                    }
25364    
25365                                    cacheResult(list);
25366    
25367                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
25368                            }
25369                            catch (Exception e) {
25370                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
25371    
25372                                    throw processException(e);
25373                            }
25374                            finally {
25375                                    closeSession(session);
25376                            }
25377                    }
25378    
25379                    return list;
25380            }
25381    
25382            /**
25383             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
25384             *
25385             * @param groupId the group ID
25386             * @param articleId the article ID
25387             * @param status the status
25388             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25389             * @return the first matching journal article
25390             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
25391             * @throws SystemException if a system exception occurred
25392             */
25393            @Override
25394            public JournalArticle findByG_A_ST_First(long groupId, String articleId,
25395                    int status, OrderByComparator orderByComparator)
25396                    throws NoSuchArticleException, SystemException {
25397                    JournalArticle journalArticle = fetchByG_A_ST_First(groupId, articleId,
25398                                    status, orderByComparator);
25399    
25400                    if (journalArticle != null) {
25401                            return journalArticle;
25402                    }
25403    
25404                    StringBundler msg = new StringBundler(8);
25405    
25406                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
25407    
25408                    msg.append("groupId=");
25409                    msg.append(groupId);
25410    
25411                    msg.append(", articleId=");
25412                    msg.append(articleId);
25413    
25414                    msg.append(", status=");
25415                    msg.append(status);
25416    
25417                    msg.append(StringPool.CLOSE_CURLY_BRACE);
25418    
25419                    throw new NoSuchArticleException(msg.toString());
25420            }
25421    
25422            /**
25423             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
25424             *
25425             * @param groupId the group ID
25426             * @param articleId the article ID
25427             * @param status the status
25428             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25429             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
25430             * @throws SystemException if a system exception occurred
25431             */
25432            @Override
25433            public JournalArticle fetchByG_A_ST_First(long groupId, String articleId,
25434                    int status, OrderByComparator orderByComparator)
25435                    throws SystemException {
25436                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status, 0,
25437                                    1, orderByComparator);
25438    
25439                    if (!list.isEmpty()) {
25440                            return list.get(0);
25441                    }
25442    
25443                    return null;
25444            }
25445    
25446            /**
25447             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
25448             *
25449             * @param groupId the group ID
25450             * @param articleId the article ID
25451             * @param status the status
25452             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25453             * @return the last matching journal article
25454             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
25455             * @throws SystemException if a system exception occurred
25456             */
25457            @Override
25458            public JournalArticle findByG_A_ST_Last(long groupId, String articleId,
25459                    int status, OrderByComparator orderByComparator)
25460                    throws NoSuchArticleException, SystemException {
25461                    JournalArticle journalArticle = fetchByG_A_ST_Last(groupId, articleId,
25462                                    status, orderByComparator);
25463    
25464                    if (journalArticle != null) {
25465                            return journalArticle;
25466                    }
25467    
25468                    StringBundler msg = new StringBundler(8);
25469    
25470                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
25471    
25472                    msg.append("groupId=");
25473                    msg.append(groupId);
25474    
25475                    msg.append(", articleId=");
25476                    msg.append(articleId);
25477    
25478                    msg.append(", status=");
25479                    msg.append(status);
25480    
25481                    msg.append(StringPool.CLOSE_CURLY_BRACE);
25482    
25483                    throw new NoSuchArticleException(msg.toString());
25484            }
25485    
25486            /**
25487             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
25488             *
25489             * @param groupId the group ID
25490             * @param articleId the article ID
25491             * @param status the status
25492             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25493             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
25494             * @throws SystemException if a system exception occurred
25495             */
25496            @Override
25497            public JournalArticle fetchByG_A_ST_Last(long groupId, String articleId,
25498                    int status, OrderByComparator orderByComparator)
25499                    throws SystemException {
25500                    int count = countByG_A_ST(groupId, articleId, status);
25501    
25502                    if (count == 0) {
25503                            return null;
25504                    }
25505    
25506                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status,
25507                                    count - 1, count, orderByComparator);
25508    
25509                    if (!list.isEmpty()) {
25510                            return list.get(0);
25511                    }
25512    
25513                    return null;
25514            }
25515    
25516            /**
25517             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
25518             *
25519             * @param id the primary key of the current journal article
25520             * @param groupId the group ID
25521             * @param articleId the article ID
25522             * @param status the status
25523             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25524             * @return the previous, current, and next journal article
25525             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
25526             * @throws SystemException if a system exception occurred
25527             */
25528            @Override
25529            public JournalArticle[] findByG_A_ST_PrevAndNext(long id, long groupId,
25530                    String articleId, int status, OrderByComparator orderByComparator)
25531                    throws NoSuchArticleException, SystemException {
25532                    JournalArticle journalArticle = findByPrimaryKey(id);
25533    
25534                    Session session = null;
25535    
25536                    try {
25537                            session = openSession();
25538    
25539                            JournalArticle[] array = new JournalArticleImpl[3];
25540    
25541                            array[0] = getByG_A_ST_PrevAndNext(session, journalArticle,
25542                                            groupId, articleId, status, orderByComparator, true);
25543    
25544                            array[1] = journalArticle;
25545    
25546                            array[2] = getByG_A_ST_PrevAndNext(session, journalArticle,
25547                                            groupId, articleId, status, orderByComparator, false);
25548    
25549                            return array;
25550                    }
25551                    catch (Exception e) {
25552                            throw processException(e);
25553                    }
25554                    finally {
25555                            closeSession(session);
25556                    }
25557            }
25558    
25559            protected JournalArticle getByG_A_ST_PrevAndNext(Session session,
25560                    JournalArticle journalArticle, long groupId, String articleId,
25561                    int status, OrderByComparator orderByComparator, boolean previous) {
25562                    StringBundler query = null;
25563    
25564                    if (orderByComparator != null) {
25565                            query = new StringBundler(6 +
25566                                            (orderByComparator.getOrderByFields().length * 6));
25567                    }
25568                    else {
25569                            query = new StringBundler(3);
25570                    }
25571    
25572                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
25573    
25574                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
25575    
25576                    boolean bindArticleId = false;
25577    
25578                    if (articleId == null) {
25579                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
25580                    }
25581                    else if (articleId.equals(StringPool.BLANK)) {
25582                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
25583                    }
25584                    else {
25585                            bindArticleId = true;
25586    
25587                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
25588                    }
25589    
25590                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
25591    
25592                    if (orderByComparator != null) {
25593                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
25594    
25595                            if (orderByConditionFields.length > 0) {
25596                                    query.append(WHERE_AND);
25597                            }
25598    
25599                            for (int i = 0; i < orderByConditionFields.length; i++) {
25600                                    query.append(_ORDER_BY_ENTITY_ALIAS);
25601                                    query.append(orderByConditionFields[i]);
25602    
25603                                    if ((i + 1) < orderByConditionFields.length) {
25604                                            if (orderByComparator.isAscending() ^ previous) {
25605                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
25606                                            }
25607                                            else {
25608                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
25609                                            }
25610                                    }
25611                                    else {
25612                                            if (orderByComparator.isAscending() ^ previous) {
25613                                                    query.append(WHERE_GREATER_THAN);
25614                                            }
25615                                            else {
25616                                                    query.append(WHERE_LESSER_THAN);
25617                                            }
25618                                    }
25619                            }
25620    
25621                            query.append(ORDER_BY_CLAUSE);
25622    
25623                            String[] orderByFields = orderByComparator.getOrderByFields();
25624    
25625                            for (int i = 0; i < orderByFields.length; i++) {
25626                                    query.append(_ORDER_BY_ENTITY_ALIAS);
25627                                    query.append(orderByFields[i]);
25628    
25629                                    if ((i + 1) < orderByFields.length) {
25630                                            if (orderByComparator.isAscending() ^ previous) {
25631                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
25632                                            }
25633                                            else {
25634                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
25635                                            }
25636                                    }
25637                                    else {
25638                                            if (orderByComparator.isAscending() ^ previous) {
25639                                                    query.append(ORDER_BY_ASC);
25640                                            }
25641                                            else {
25642                                                    query.append(ORDER_BY_DESC);
25643                                            }
25644                                    }
25645                            }
25646                    }
25647                    else {
25648                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
25649                    }
25650    
25651                    String sql = query.toString();
25652    
25653                    Query q = session.createQuery(sql);
25654    
25655                    q.setFirstResult(0);
25656                    q.setMaxResults(2);
25657    
25658                    QueryPos qPos = QueryPos.getInstance(q);
25659    
25660                    qPos.add(groupId);
25661    
25662                    if (bindArticleId) {
25663                            qPos.add(articleId);
25664                    }
25665    
25666                    qPos.add(status);
25667    
25668                    if (orderByComparator != null) {
25669                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
25670    
25671                            for (Object value : values) {
25672                                    qPos.add(value);
25673                            }
25674                    }
25675    
25676                    List<JournalArticle> list = q.list();
25677    
25678                    if (list.size() == 2) {
25679                            return list.get(1);
25680                    }
25681                    else {
25682                            return null;
25683                    }
25684            }
25685    
25686            /**
25687             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
25688             *
25689             * @param groupId the group ID
25690             * @param articleId the article ID
25691             * @param status the status
25692             * @return the matching journal articles that the user has permission to view
25693             * @throws SystemException if a system exception occurred
25694             */
25695            @Override
25696            public List<JournalArticle> filterFindByG_A_ST(long groupId,
25697                    String articleId, int status) throws SystemException {
25698                    return filterFindByG_A_ST(groupId, articleId, status,
25699                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
25700            }
25701    
25702            /**
25703             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
25704             *
25705             * <p>
25706             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
25707             * </p>
25708             *
25709             * @param groupId the group ID
25710             * @param articleId the article ID
25711             * @param status the status
25712             * @param start the lower bound of the range of journal articles
25713             * @param end the upper bound of the range of journal articles (not inclusive)
25714             * @return the range of matching journal articles that the user has permission to view
25715             * @throws SystemException if a system exception occurred
25716             */
25717            @Override
25718            public List<JournalArticle> filterFindByG_A_ST(long groupId,
25719                    String articleId, int status, int start, int end)
25720                    throws SystemException {
25721                    return filterFindByG_A_ST(groupId, articleId, status, start, end, null);
25722            }
25723    
25724            /**
25725             * 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;.
25726             *
25727             * <p>
25728             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
25729             * </p>
25730             *
25731             * @param groupId the group ID
25732             * @param articleId the article ID
25733             * @param status the status
25734             * @param start the lower bound of the range of journal articles
25735             * @param end the upper bound of the range of journal articles (not inclusive)
25736             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
25737             * @return the ordered range of matching journal articles that the user has permission to view
25738             * @throws SystemException if a system exception occurred
25739             */
25740            @Override
25741            public List<JournalArticle> filterFindByG_A_ST(long groupId,
25742                    String articleId, int status, int start, int end,
25743                    OrderByComparator orderByComparator) throws SystemException {
25744                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
25745                            return findByG_A_ST(groupId, articleId, status, start, end,
25746                                    orderByComparator);
25747                    }
25748    
25749                    StringBundler query = null;
25750    
25751                    if (orderByComparator != null) {
25752                            query = new StringBundler(5 +
25753                                            (orderByComparator.getOrderByFields().length * 3));
25754                    }
25755                    else {
25756                            query = new StringBundler(5);
25757                    }
25758    
25759                    if (getDB().isSupportsInlineDistinct()) {
25760                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
25761                    }
25762                    else {
25763                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
25764                    }
25765    
25766                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
25767    
25768                    boolean bindArticleId = false;
25769    
25770                    if (articleId == null) {
25771                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
25772                    }
25773                    else if (articleId.equals(StringPool.BLANK)) {
25774                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
25775                    }
25776                    else {
25777                            bindArticleId = true;
25778    
25779                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
25780                    }
25781    
25782                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
25783    
25784                    if (!getDB().isSupportsInlineDistinct()) {
25785                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
25786                    }
25787    
25788                    if (orderByComparator != null) {
25789                            if (getDB().isSupportsInlineDistinct()) {
25790                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
25791                                            orderByComparator, true);
25792                            }
25793                            else {
25794                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
25795                                            orderByComparator, true);
25796                            }
25797                    }
25798                    else {
25799                            if (getDB().isSupportsInlineDistinct()) {
25800                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
25801                            }
25802                            else {
25803                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
25804                            }
25805                    }
25806    
25807                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
25808                                    JournalArticle.class.getName(),
25809                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
25810    
25811                    Session session = null;
25812    
25813                    try {
25814                            session = openSession();
25815    
25816                            SQLQuery q = session.createSQLQuery(sql);
25817    
25818                            if (getDB().isSupportsInlineDistinct()) {
25819                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
25820                            }
25821                            else {
25822                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
25823                            }
25824    
25825                            QueryPos qPos = QueryPos.getInstance(q);
25826    
25827                            qPos.add(groupId);
25828    
25829                            if (bindArticleId) {
25830                                    qPos.add(articleId);
25831                            }
25832    
25833                            qPos.add(status);
25834    
25835                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
25836                                    end);
25837                    }
25838                    catch (Exception e) {
25839                            throw processException(e);
25840                    }
25841                    finally {
25842                            closeSession(session);
25843                    }
25844            }
25845    
25846            /**
25847             * 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;.
25848             *
25849             * @param id the primary key of the current journal article
25850             * @param groupId the group ID
25851             * @param articleId the article ID
25852             * @param status the status
25853             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25854             * @return the previous, current, and next journal article
25855             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
25856             * @throws SystemException if a system exception occurred
25857             */
25858            @Override
25859            public JournalArticle[] filterFindByG_A_ST_PrevAndNext(long id,
25860                    long groupId, String articleId, int status,
25861                    OrderByComparator orderByComparator)
25862                    throws NoSuchArticleException, SystemException {
25863                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
25864                            return findByG_A_ST_PrevAndNext(id, groupId, articleId, status,
25865                                    orderByComparator);
25866                    }
25867    
25868                    JournalArticle journalArticle = findByPrimaryKey(id);
25869    
25870                    Session session = null;
25871    
25872                    try {
25873                            session = openSession();
25874    
25875                            JournalArticle[] array = new JournalArticleImpl[3];
25876    
25877                            array[0] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
25878                                            groupId, articleId, status, orderByComparator, true);
25879    
25880                            array[1] = journalArticle;
25881    
25882                            array[2] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
25883                                            groupId, articleId, status, orderByComparator, false);
25884    
25885                            return array;
25886                    }
25887                    catch (Exception e) {
25888                            throw processException(e);
25889                    }
25890                    finally {
25891                            closeSession(session);
25892                    }
25893            }
25894    
25895            protected JournalArticle filterGetByG_A_ST_PrevAndNext(Session session,
25896                    JournalArticle journalArticle, long groupId, String articleId,
25897                    int status, OrderByComparator orderByComparator, boolean previous) {
25898                    StringBundler query = null;
25899    
25900                    if (orderByComparator != null) {
25901                            query = new StringBundler(6 +
25902                                            (orderByComparator.getOrderByFields().length * 6));
25903                    }
25904                    else {
25905                            query = new StringBundler(3);
25906                    }
25907    
25908                    if (getDB().isSupportsInlineDistinct()) {
25909                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
25910                    }
25911                    else {
25912                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
25913                    }
25914    
25915                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
25916    
25917                    boolean bindArticleId = false;
25918    
25919                    if (articleId == null) {
25920                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
25921                    }
25922                    else if (articleId.equals(StringPool.BLANK)) {
25923                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
25924                    }
25925                    else {
25926                            bindArticleId = true;
25927    
25928                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
25929                    }
25930    
25931                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
25932    
25933                    if (!getDB().isSupportsInlineDistinct()) {
25934                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
25935                    }
25936    
25937                    if (orderByComparator != null) {
25938                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
25939    
25940                            if (orderByConditionFields.length > 0) {
25941                                    query.append(WHERE_AND);
25942                            }
25943    
25944                            for (int i = 0; i < orderByConditionFields.length; i++) {
25945                                    if (getDB().isSupportsInlineDistinct()) {
25946                                            query.append(_ORDER_BY_ENTITY_ALIAS);
25947                                    }
25948                                    else {
25949                                            query.append(_ORDER_BY_ENTITY_TABLE);
25950                                    }
25951    
25952                                    query.append(orderByConditionFields[i]);
25953    
25954                                    if ((i + 1) < orderByConditionFields.length) {
25955                                            if (orderByComparator.isAscending() ^ previous) {
25956                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
25957                                            }
25958                                            else {
25959                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
25960                                            }
25961                                    }
25962                                    else {
25963                                            if (orderByComparator.isAscending() ^ previous) {
25964                                                    query.append(WHERE_GREATER_THAN);
25965                                            }
25966                                            else {
25967                                                    query.append(WHERE_LESSER_THAN);
25968                                            }
25969                                    }
25970                            }
25971    
25972                            query.append(ORDER_BY_CLAUSE);
25973    
25974                            String[] orderByFields = orderByComparator.getOrderByFields();
25975    
25976                            for (int i = 0; i < orderByFields.length; i++) {
25977                                    if (getDB().isSupportsInlineDistinct()) {
25978                                            query.append(_ORDER_BY_ENTITY_ALIAS);
25979                                    }
25980                                    else {
25981                                            query.append(_ORDER_BY_ENTITY_TABLE);
25982                                    }
25983    
25984                                    query.append(orderByFields[i]);
25985    
25986                                    if ((i + 1) < orderByFields.length) {
25987                                            if (orderByComparator.isAscending() ^ previous) {
25988                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
25989                                            }
25990                                            else {
25991                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
25992                                            }
25993                                    }
25994                                    else {
25995                                            if (orderByComparator.isAscending() ^ previous) {
25996                                                    query.append(ORDER_BY_ASC);
25997                                            }
25998                                            else {
25999                                                    query.append(ORDER_BY_DESC);
26000                                            }
26001                                    }
26002                            }
26003                    }
26004                    else {
26005                            if (getDB().isSupportsInlineDistinct()) {
26006                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
26007                            }
26008                            else {
26009                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
26010                            }
26011                    }
26012    
26013                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
26014                                    JournalArticle.class.getName(),
26015                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
26016    
26017                    SQLQuery q = session.createSQLQuery(sql);
26018    
26019                    q.setFirstResult(0);
26020                    q.setMaxResults(2);
26021    
26022                    if (getDB().isSupportsInlineDistinct()) {
26023                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
26024                    }
26025                    else {
26026                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
26027                    }
26028    
26029                    QueryPos qPos = QueryPos.getInstance(q);
26030    
26031                    qPos.add(groupId);
26032    
26033                    if (bindArticleId) {
26034                            qPos.add(articleId);
26035                    }
26036    
26037                    qPos.add(status);
26038    
26039                    if (orderByComparator != null) {
26040                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
26041    
26042                            for (Object value : values) {
26043                                    qPos.add(value);
26044                            }
26045                    }
26046    
26047                    List<JournalArticle> list = q.list();
26048    
26049                    if (list.size() == 2) {
26050                            return list.get(1);
26051                    }
26052                    else {
26053                            return null;
26054                    }
26055            }
26056    
26057            /**
26058             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
26059             *
26060             * @param groupId the group ID
26061             * @param articleId the article ID
26062             * @param statuses the statuses
26063             * @return the matching journal articles that the user has permission to view
26064             * @throws SystemException if a system exception occurred
26065             */
26066            @Override
26067            public List<JournalArticle> filterFindByG_A_ST(long groupId,
26068                    String articleId, int[] statuses) throws SystemException {
26069                    return filterFindByG_A_ST(groupId, articleId, statuses,
26070                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
26071            }
26072    
26073            /**
26074             * 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;.
26075             *
26076             * <p>
26077             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
26078             * </p>
26079             *
26080             * @param groupId the group ID
26081             * @param articleId the article ID
26082             * @param statuses the statuses
26083             * @param start the lower bound of the range of journal articles
26084             * @param end the upper bound of the range of journal articles (not inclusive)
26085             * @return the range of matching journal articles that the user has permission to view
26086             * @throws SystemException if a system exception occurred
26087             */
26088            @Override
26089            public List<JournalArticle> filterFindByG_A_ST(long groupId,
26090                    String articleId, int[] statuses, int start, int end)
26091                    throws SystemException {
26092                    return filterFindByG_A_ST(groupId, articleId, statuses, start, end, null);
26093            }
26094    
26095            /**
26096             * 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;.
26097             *
26098             * <p>
26099             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
26100             * </p>
26101             *
26102             * @param groupId the group ID
26103             * @param articleId the article ID
26104             * @param statuses the statuses
26105             * @param start the lower bound of the range of journal articles
26106             * @param end the upper bound of the range of journal articles (not inclusive)
26107             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
26108             * @return the ordered range of matching journal articles that the user has permission to view
26109             * @throws SystemException if a system exception occurred
26110             */
26111            @Override
26112            public List<JournalArticle> filterFindByG_A_ST(long groupId,
26113                    String articleId, int[] statuses, int start, int end,
26114                    OrderByComparator orderByComparator) throws SystemException {
26115                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
26116                            return findByG_A_ST(groupId, articleId, statuses, start, end,
26117                                    orderByComparator);
26118                    }
26119    
26120                    StringBundler query = new StringBundler();
26121    
26122                    if (getDB().isSupportsInlineDistinct()) {
26123                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
26124                    }
26125                    else {
26126                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
26127                    }
26128    
26129                    boolean conjunctionable = false;
26130    
26131                    if (conjunctionable) {
26132                            query.append(WHERE_AND);
26133                    }
26134    
26135                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
26136    
26137                    conjunctionable = true;
26138    
26139                    if (conjunctionable) {
26140                            query.append(WHERE_AND);
26141                    }
26142    
26143                    boolean bindArticleId = false;
26144    
26145                    if (articleId == null) {
26146                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
26147                    }
26148                    else if (articleId.equals(StringPool.BLANK)) {
26149                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
26150                    }
26151                    else {
26152                            bindArticleId = true;
26153    
26154                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
26155                    }
26156    
26157                    conjunctionable = true;
26158    
26159                    if ((statuses == null) || (statuses.length > 0)) {
26160                            if (conjunctionable) {
26161                                    query.append(WHERE_AND);
26162                            }
26163    
26164                            query.append(StringPool.OPEN_PARENTHESIS);
26165    
26166                            for (int i = 0; i < statuses.length; i++) {
26167                                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
26168    
26169                                    if ((i + 1) < statuses.length) {
26170                                            query.append(WHERE_OR);
26171                                    }
26172                            }
26173    
26174                            query.append(StringPool.CLOSE_PARENTHESIS);
26175    
26176                            conjunctionable = true;
26177                    }
26178    
26179                    if (!getDB().isSupportsInlineDistinct()) {
26180                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
26181                    }
26182    
26183                    if (orderByComparator != null) {
26184                            if (getDB().isSupportsInlineDistinct()) {
26185                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
26186                                            orderByComparator, true);
26187                            }
26188                            else {
26189                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
26190                                            orderByComparator, true);
26191                            }
26192                    }
26193                    else {
26194                            if (getDB().isSupportsInlineDistinct()) {
26195                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
26196                            }
26197                            else {
26198                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
26199                            }
26200                    }
26201    
26202                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
26203                                    JournalArticle.class.getName(),
26204                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
26205    
26206                    Session session = null;
26207    
26208                    try {
26209                            session = openSession();
26210    
26211                            SQLQuery q = session.createSQLQuery(sql);
26212    
26213                            if (getDB().isSupportsInlineDistinct()) {
26214                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
26215                            }
26216                            else {
26217                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
26218                            }
26219    
26220                            QueryPos qPos = QueryPos.getInstance(q);
26221    
26222                            qPos.add(groupId);
26223    
26224                            if (bindArticleId) {
26225                                    qPos.add(articleId);
26226                            }
26227    
26228                            if (statuses != null) {
26229                                    qPos.add(statuses);
26230                            }
26231    
26232                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
26233                                    end);
26234                    }
26235                    catch (Exception e) {
26236                            throw processException(e);
26237                    }
26238                    finally {
26239                            closeSession(session);
26240                    }
26241            }
26242    
26243            /**
26244             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
26245             *
26246             * <p>
26247             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
26248             * </p>
26249             *
26250             * @param groupId the group ID
26251             * @param articleId the article ID
26252             * @param statuses the statuses
26253             * @return the matching journal articles
26254             * @throws SystemException if a system exception occurred
26255             */
26256            @Override
26257            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
26258                    int[] statuses) throws SystemException {
26259                    return findByG_A_ST(groupId, articleId, statuses, QueryUtil.ALL_POS,
26260                            QueryUtil.ALL_POS, null);
26261            }
26262    
26263            /**
26264             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
26265             *
26266             * <p>
26267             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
26268             * </p>
26269             *
26270             * @param groupId the group ID
26271             * @param articleId the article ID
26272             * @param statuses the statuses
26273             * @param start the lower bound of the range of journal articles
26274             * @param end the upper bound of the range of journal articles (not inclusive)
26275             * @return the range of matching journal articles
26276             * @throws SystemException if a system exception occurred
26277             */
26278            @Override
26279            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
26280                    int[] statuses, int start, int end) throws SystemException {
26281                    return findByG_A_ST(groupId, articleId, statuses, start, end, null);
26282            }
26283    
26284            /**
26285             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
26286             *
26287             * <p>
26288             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
26289             * </p>
26290             *
26291             * @param groupId the group ID
26292             * @param articleId the article ID
26293             * @param statuses the statuses
26294             * @param start the lower bound of the range of journal articles
26295             * @param end the upper bound of the range of journal articles (not inclusive)
26296             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
26297             * @return the ordered range of matching journal articles
26298             * @throws SystemException if a system exception occurred
26299             */
26300            @Override
26301            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
26302                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
26303                    throws SystemException {
26304                    if ((statuses != null) && (statuses.length == 1)) {
26305                            return findByG_A_ST(groupId, articleId, statuses[0], start, end,
26306                                    orderByComparator);
26307                    }
26308    
26309                    boolean pagination = true;
26310                    Object[] finderArgs = null;
26311    
26312                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
26313                                    (orderByComparator == null)) {
26314                            pagination = false;
26315                            finderArgs = new Object[] {
26316                                            groupId, articleId, StringUtil.merge(statuses)
26317                                    };
26318                    }
26319                    else {
26320                            finderArgs = new Object[] {
26321                                            groupId, articleId, StringUtil.merge(statuses),
26322                                            
26323                                            start, end, orderByComparator
26324                                    };
26325                    }
26326    
26327                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
26328                                    finderArgs, this);
26329    
26330                    if ((list != null) && !list.isEmpty()) {
26331                            for (JournalArticle journalArticle : list) {
26332                                    if ((groupId != journalArticle.getGroupId()) ||
26333                                                    !Validator.equals(articleId,
26334                                                            journalArticle.getArticleId()) ||
26335                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
26336                                            list = null;
26337    
26338                                            break;
26339                                    }
26340                            }
26341                    }
26342    
26343                    if (list == null) {
26344                            StringBundler query = new StringBundler();
26345    
26346                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
26347    
26348                            boolean conjunctionable = false;
26349    
26350                            if (conjunctionable) {
26351                                    query.append(WHERE_AND);
26352                            }
26353    
26354                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
26355    
26356                            conjunctionable = true;
26357    
26358                            if (conjunctionable) {
26359                                    query.append(WHERE_AND);
26360                            }
26361    
26362                            boolean bindArticleId = false;
26363    
26364                            if (articleId == null) {
26365                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
26366                            }
26367                            else if (articleId.equals(StringPool.BLANK)) {
26368                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
26369                            }
26370                            else {
26371                                    bindArticleId = true;
26372    
26373                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
26374                            }
26375    
26376                            conjunctionable = true;
26377    
26378                            if ((statuses == null) || (statuses.length > 0)) {
26379                                    if (conjunctionable) {
26380                                            query.append(WHERE_AND);
26381                                    }
26382    
26383                                    query.append(StringPool.OPEN_PARENTHESIS);
26384    
26385                                    for (int i = 0; i < statuses.length; i++) {
26386                                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
26387    
26388                                            if ((i + 1) < statuses.length) {
26389                                                    query.append(WHERE_OR);
26390                                            }
26391                                    }
26392    
26393                                    query.append(StringPool.CLOSE_PARENTHESIS);
26394    
26395                                    conjunctionable = true;
26396                            }
26397    
26398                            if (orderByComparator != null) {
26399                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
26400                                            orderByComparator);
26401                            }
26402                            else
26403                             if (pagination) {
26404                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
26405                            }
26406    
26407                            String sql = query.toString();
26408    
26409                            Session session = null;
26410    
26411                            try {
26412                                    session = openSession();
26413    
26414                                    Query q = session.createQuery(sql);
26415    
26416                                    QueryPos qPos = QueryPos.getInstance(q);
26417    
26418                                    qPos.add(groupId);
26419    
26420                                    if (bindArticleId) {
26421                                            qPos.add(articleId);
26422                                    }
26423    
26424                                    if (statuses != null) {
26425                                            qPos.add(statuses);
26426                                    }
26427    
26428                                    if (!pagination) {
26429                                            list = (List<JournalArticle>)QueryUtil.list(q,
26430                                                            getDialect(), start, end, false);
26431    
26432                                            Collections.sort(list);
26433    
26434                                            list = new UnmodifiableList<JournalArticle>(list);
26435                                    }
26436                                    else {
26437                                            list = (List<JournalArticle>)QueryUtil.list(q,
26438                                                            getDialect(), start, end);
26439                                    }
26440    
26441                                    cacheResult(list);
26442    
26443                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
26444                                            finderArgs, list);
26445                            }
26446                            catch (Exception e) {
26447                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
26448                                            finderArgs);
26449    
26450                                    throw processException(e);
26451                            }
26452                            finally {
26453                                    closeSession(session);
26454                            }
26455                    }
26456    
26457                    return list;
26458            }
26459    
26460            /**
26461             * Removes all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63; from the database.
26462             *
26463             * @param groupId the group ID
26464             * @param articleId the article ID
26465             * @param status the status
26466             * @throws SystemException if a system exception occurred
26467             */
26468            @Override
26469            public void removeByG_A_ST(long groupId, String articleId, int status)
26470                    throws SystemException {
26471                    for (JournalArticle journalArticle : findByG_A_ST(groupId, articleId,
26472                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
26473                            remove(journalArticle);
26474                    }
26475            }
26476    
26477            /**
26478             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
26479             *
26480             * @param groupId the group ID
26481             * @param articleId the article ID
26482             * @param status the status
26483             * @return the number of matching journal articles
26484             * @throws SystemException if a system exception occurred
26485             */
26486            @Override
26487            public int countByG_A_ST(long groupId, String articleId, int status)
26488                    throws SystemException {
26489                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A_ST;
26490    
26491                    Object[] finderArgs = new Object[] { groupId, articleId, status };
26492    
26493                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
26494                                    this);
26495    
26496                    if (count == null) {
26497                            StringBundler query = new StringBundler(4);
26498    
26499                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
26500    
26501                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
26502    
26503                            boolean bindArticleId = false;
26504    
26505                            if (articleId == null) {
26506                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
26507                            }
26508                            else if (articleId.equals(StringPool.BLANK)) {
26509                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
26510                            }
26511                            else {
26512                                    bindArticleId = true;
26513    
26514                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
26515                            }
26516    
26517                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
26518    
26519                            String sql = query.toString();
26520    
26521                            Session session = null;
26522    
26523                            try {
26524                                    session = openSession();
26525    
26526                                    Query q = session.createQuery(sql);
26527    
26528                                    QueryPos qPos = QueryPos.getInstance(q);
26529    
26530                                    qPos.add(groupId);
26531    
26532                                    if (bindArticleId) {
26533                                            qPos.add(articleId);
26534                                    }
26535    
26536                                    qPos.add(status);
26537    
26538                                    count = (Long)q.uniqueResult();
26539    
26540                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
26541                            }
26542                            catch (Exception e) {
26543                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
26544    
26545                                    throw processException(e);
26546                            }
26547                            finally {
26548                                    closeSession(session);
26549                            }
26550                    }
26551    
26552                    return count.intValue();
26553            }
26554    
26555            /**
26556             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
26557             *
26558             * @param groupId the group ID
26559             * @param articleId the article ID
26560             * @param statuses the statuses
26561             * @return the number of matching journal articles
26562             * @throws SystemException if a system exception occurred
26563             */
26564            @Override
26565            public int countByG_A_ST(long groupId, String articleId, int[] statuses)
26566                    throws SystemException {
26567                    Object[] finderArgs = new Object[] {
26568                                    groupId, articleId, StringUtil.merge(statuses)
26569                            };
26570    
26571                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
26572                                    finderArgs, this);
26573    
26574                    if (count == null) {
26575                            StringBundler query = new StringBundler();
26576    
26577                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
26578    
26579                            boolean conjunctionable = false;
26580    
26581                            if (conjunctionable) {
26582                                    query.append(WHERE_AND);
26583                            }
26584    
26585                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
26586    
26587                            conjunctionable = true;
26588    
26589                            if (conjunctionable) {
26590                                    query.append(WHERE_AND);
26591                            }
26592    
26593                            boolean bindArticleId = false;
26594    
26595                            if (articleId == null) {
26596                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
26597                            }
26598                            else if (articleId.equals(StringPool.BLANK)) {
26599                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
26600                            }
26601                            else {
26602                                    bindArticleId = true;
26603    
26604                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
26605                            }
26606    
26607                            conjunctionable = true;
26608    
26609                            if ((statuses == null) || (statuses.length > 0)) {
26610                                    if (conjunctionable) {
26611                                            query.append(WHERE_AND);
26612                                    }
26613    
26614                                    query.append(StringPool.OPEN_PARENTHESIS);
26615    
26616                                    for (int i = 0; i < statuses.length; i++) {
26617                                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
26618    
26619                                            if ((i + 1) < statuses.length) {
26620                                                    query.append(WHERE_OR);
26621                                            }
26622                                    }
26623    
26624                                    query.append(StringPool.CLOSE_PARENTHESIS);
26625    
26626                                    conjunctionable = true;
26627                            }
26628    
26629                            String sql = query.toString();
26630    
26631                            Session session = null;
26632    
26633                            try {
26634                                    session = openSession();
26635    
26636                                    Query q = session.createQuery(sql);
26637    
26638                                    QueryPos qPos = QueryPos.getInstance(q);
26639    
26640                                    qPos.add(groupId);
26641    
26642                                    if (bindArticleId) {
26643                                            qPos.add(articleId);
26644                                    }
26645    
26646                                    if (statuses != null) {
26647                                            qPos.add(statuses);
26648                                    }
26649    
26650                                    count = (Long)q.uniqueResult();
26651    
26652                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
26653                                            finderArgs, count);
26654                            }
26655                            catch (Exception e) {
26656                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
26657                                            finderArgs);
26658    
26659                                    throw processException(e);
26660                            }
26661                            finally {
26662                                    closeSession(session);
26663                            }
26664                    }
26665    
26666                    return count.intValue();
26667            }
26668    
26669            /**
26670             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
26671             *
26672             * @param groupId the group ID
26673             * @param articleId the article ID
26674             * @param status the status
26675             * @return the number of matching journal articles that the user has permission to view
26676             * @throws SystemException if a system exception occurred
26677             */
26678            @Override
26679            public int filterCountByG_A_ST(long groupId, String articleId, int status)
26680                    throws SystemException {
26681                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
26682                            return countByG_A_ST(groupId, articleId, status);
26683                    }
26684    
26685                    StringBundler query = new StringBundler(4);
26686    
26687                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
26688    
26689                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
26690    
26691                    boolean bindArticleId = false;
26692    
26693                    if (articleId == null) {
26694                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
26695                    }
26696                    else if (articleId.equals(StringPool.BLANK)) {
26697                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
26698                    }
26699                    else {
26700                            bindArticleId = true;
26701    
26702                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
26703                    }
26704    
26705                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
26706    
26707                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
26708                                    JournalArticle.class.getName(),
26709                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
26710    
26711                    Session session = null;
26712    
26713                    try {
26714                            session = openSession();
26715    
26716                            SQLQuery q = session.createSQLQuery(sql);
26717    
26718                            q.addScalar(COUNT_COLUMN_NAME,
26719                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
26720    
26721                            QueryPos qPos = QueryPos.getInstance(q);
26722    
26723                            qPos.add(groupId);
26724    
26725                            if (bindArticleId) {
26726                                    qPos.add(articleId);
26727                            }
26728    
26729                            qPos.add(status);
26730    
26731                            Long count = (Long)q.uniqueResult();
26732    
26733                            return count.intValue();
26734                    }
26735                    catch (Exception e) {
26736                            throw processException(e);
26737                    }
26738                    finally {
26739                            closeSession(session);
26740                    }
26741            }
26742    
26743            /**
26744             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
26745             *
26746             * @param groupId the group ID
26747             * @param articleId the article ID
26748             * @param statuses the statuses
26749             * @return the number of matching journal articles that the user has permission to view
26750             * @throws SystemException if a system exception occurred
26751             */
26752            @Override
26753            public int filterCountByG_A_ST(long groupId, String articleId,
26754                    int[] statuses) throws SystemException {
26755                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
26756                            return countByG_A_ST(groupId, articleId, statuses);
26757                    }
26758    
26759                    StringBundler query = new StringBundler();
26760    
26761                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
26762    
26763                    boolean conjunctionable = false;
26764    
26765                    if (conjunctionable) {
26766                            query.append(WHERE_AND);
26767                    }
26768    
26769                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
26770    
26771                    conjunctionable = true;
26772    
26773                    if (conjunctionable) {
26774                            query.append(WHERE_AND);
26775                    }
26776    
26777                    boolean bindArticleId = false;
26778    
26779                    if (articleId == null) {
26780                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
26781                    }
26782                    else if (articleId.equals(StringPool.BLANK)) {
26783                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
26784                    }
26785                    else {
26786                            bindArticleId = true;
26787    
26788                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
26789                    }
26790    
26791                    conjunctionable = true;
26792    
26793                    if ((statuses == null) || (statuses.length > 0)) {
26794                            if (conjunctionable) {
26795                                    query.append(WHERE_AND);
26796                            }
26797    
26798                            query.append(StringPool.OPEN_PARENTHESIS);
26799    
26800                            for (int i = 0; i < statuses.length; i++) {
26801                                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
26802    
26803                                    if ((i + 1) < statuses.length) {
26804                                            query.append(WHERE_OR);
26805                                    }
26806                            }
26807    
26808                            query.append(StringPool.CLOSE_PARENTHESIS);
26809    
26810                            conjunctionable = true;
26811                    }
26812    
26813                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
26814                                    JournalArticle.class.getName(),
26815                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
26816    
26817                    Session session = null;
26818    
26819                    try {
26820                            session = openSession();
26821    
26822                            SQLQuery q = session.createSQLQuery(sql);
26823    
26824                            q.addScalar(COUNT_COLUMN_NAME,
26825                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
26826    
26827                            QueryPos qPos = QueryPos.getInstance(q);
26828    
26829                            qPos.add(groupId);
26830    
26831                            if (bindArticleId) {
26832                                    qPos.add(articleId);
26833                            }
26834    
26835                            if (statuses != null) {
26836                                    qPos.add(statuses);
26837                            }
26838    
26839                            Long count = (Long)q.uniqueResult();
26840    
26841                            return count.intValue();
26842                    }
26843                    catch (Exception e) {
26844                            throw processException(e);
26845                    }
26846                    finally {
26847                            closeSession(session);
26848                    }
26849            }
26850    
26851            private static final String _FINDER_COLUMN_G_A_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
26852            private static final String _FINDER_COLUMN_G_A_ST_GROUPID_5 = "(" +
26853                    removeConjunction(_FINDER_COLUMN_G_A_ST_GROUPID_2) + ")";
26854            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
26855            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
26856            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '') AND ";
26857            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_4 = "(" +
26858                    removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_1) + ")";
26859            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_5 = "(" +
26860                    removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_2) + ")";
26861            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_6 = "(" +
26862                    removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_3) + ")";
26863            private static final String _FINDER_COLUMN_G_A_ST_STATUS_2 = "journalArticle.status = ?";
26864            private static final String _FINDER_COLUMN_G_A_ST_STATUS_5 = "(" +
26865                    removeConjunction(_FINDER_COLUMN_G_A_ST_STATUS_2) + ")";
26866            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_NOTST =
26867                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
26868                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
26869                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
26870                            "findByG_A_NotST",
26871                            new String[] {
26872                                    Long.class.getName(), String.class.getName(),
26873                                    Integer.class.getName(),
26874                                    
26875                            Integer.class.getName(), Integer.class.getName(),
26876                                    OrderByComparator.class.getName()
26877                            });
26878            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_NOTST =
26879                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
26880                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
26881                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_A_NotST",
26882                            new String[] {
26883                                    Long.class.getName(), String.class.getName(),
26884                                    Integer.class.getName()
26885                            });
26886    
26887            /**
26888             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26889             *
26890             * @param groupId the group ID
26891             * @param articleId the article ID
26892             * @param status the status
26893             * @return the matching journal articles
26894             * @throws SystemException if a system exception occurred
26895             */
26896            @Override
26897            public List<JournalArticle> findByG_A_NotST(long groupId, String articleId,
26898                    int status) throws SystemException {
26899                    return findByG_A_NotST(groupId, articleId, status, QueryUtil.ALL_POS,
26900                            QueryUtil.ALL_POS, null);
26901            }
26902    
26903            /**
26904             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26905             *
26906             * <p>
26907             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
26908             * </p>
26909             *
26910             * @param groupId the group ID
26911             * @param articleId the article ID
26912             * @param status the status
26913             * @param start the lower bound of the range of journal articles
26914             * @param end the upper bound of the range of journal articles (not inclusive)
26915             * @return the range of matching journal articles
26916             * @throws SystemException if a system exception occurred
26917             */
26918            @Override
26919            public List<JournalArticle> findByG_A_NotST(long groupId, String articleId,
26920                    int status, int start, int end) throws SystemException {
26921                    return findByG_A_NotST(groupId, articleId, status, start, end, null);
26922            }
26923    
26924            /**
26925             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26926             *
26927             * <p>
26928             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
26929             * </p>
26930             *
26931             * @param groupId the group ID
26932             * @param articleId the article ID
26933             * @param status the status
26934             * @param start the lower bound of the range of journal articles
26935             * @param end the upper bound of the range of journal articles (not inclusive)
26936             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
26937             * @return the ordered range of matching journal articles
26938             * @throws SystemException if a system exception occurred
26939             */
26940            @Override
26941            public List<JournalArticle> findByG_A_NotST(long groupId, String articleId,
26942                    int status, int start, int end, OrderByComparator orderByComparator)
26943                    throws SystemException {
26944                    boolean pagination = true;
26945                    FinderPath finderPath = null;
26946                    Object[] finderArgs = null;
26947    
26948                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_NOTST;
26949                    finderArgs = new Object[] {
26950                                    groupId, articleId, status,
26951                                    
26952                                    start, end, orderByComparator
26953                            };
26954    
26955                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
26956                                    finderArgs, this);
26957    
26958                    if ((list != null) && !list.isEmpty()) {
26959                            for (JournalArticle journalArticle : list) {
26960                                    if ((groupId != journalArticle.getGroupId()) ||
26961                                                    !Validator.equals(articleId,
26962                                                            journalArticle.getArticleId()) ||
26963                                                    (status == journalArticle.getStatus())) {
26964                                            list = null;
26965    
26966                                            break;
26967                                    }
26968                            }
26969                    }
26970    
26971                    if (list == null) {
26972                            StringBundler query = null;
26973    
26974                            if (orderByComparator != null) {
26975                                    query = new StringBundler(5 +
26976                                                    (orderByComparator.getOrderByFields().length * 3));
26977                            }
26978                            else {
26979                                    query = new StringBundler(5);
26980                            }
26981    
26982                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
26983    
26984                            query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
26985    
26986                            boolean bindArticleId = false;
26987    
26988                            if (articleId == null) {
26989                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
26990                            }
26991                            else if (articleId.equals(StringPool.BLANK)) {
26992                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
26993                            }
26994                            else {
26995                                    bindArticleId = true;
26996    
26997                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
26998                            }
26999    
27000                            query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
27001    
27002                            if (orderByComparator != null) {
27003                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
27004                                            orderByComparator);
27005                            }
27006                            else
27007                             if (pagination) {
27008                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
27009                            }
27010    
27011                            String sql = query.toString();
27012    
27013                            Session session = null;
27014    
27015                            try {
27016                                    session = openSession();
27017    
27018                                    Query q = session.createQuery(sql);
27019    
27020                                    QueryPos qPos = QueryPos.getInstance(q);
27021    
27022                                    qPos.add(groupId);
27023    
27024                                    if (bindArticleId) {
27025                                            qPos.add(articleId);
27026                                    }
27027    
27028                                    qPos.add(status);
27029    
27030                                    if (!pagination) {
27031                                            list = (List<JournalArticle>)QueryUtil.list(q,
27032                                                            getDialect(), start, end, false);
27033    
27034                                            Collections.sort(list);
27035    
27036                                            list = new UnmodifiableList<JournalArticle>(list);
27037                                    }
27038                                    else {
27039                                            list = (List<JournalArticle>)QueryUtil.list(q,
27040                                                            getDialect(), start, end);
27041                                    }
27042    
27043                                    cacheResult(list);
27044    
27045                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
27046                            }
27047                            catch (Exception e) {
27048                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
27049    
27050                                    throw processException(e);
27051                            }
27052                            finally {
27053                                    closeSession(session);
27054                            }
27055                    }
27056    
27057                    return list;
27058            }
27059    
27060            /**
27061             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
27062             *
27063             * @param groupId the group ID
27064             * @param articleId the article ID
27065             * @param status the status
27066             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27067             * @return the first matching journal article
27068             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
27069             * @throws SystemException if a system exception occurred
27070             */
27071            @Override
27072            public JournalArticle findByG_A_NotST_First(long groupId, String articleId,
27073                    int status, OrderByComparator orderByComparator)
27074                    throws NoSuchArticleException, SystemException {
27075                    JournalArticle journalArticle = fetchByG_A_NotST_First(groupId,
27076                                    articleId, status, orderByComparator);
27077    
27078                    if (journalArticle != null) {
27079                            return journalArticle;
27080                    }
27081    
27082                    StringBundler msg = new StringBundler(8);
27083    
27084                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
27085    
27086                    msg.append("groupId=");
27087                    msg.append(groupId);
27088    
27089                    msg.append(", articleId=");
27090                    msg.append(articleId);
27091    
27092                    msg.append(", status=");
27093                    msg.append(status);
27094    
27095                    msg.append(StringPool.CLOSE_CURLY_BRACE);
27096    
27097                    throw new NoSuchArticleException(msg.toString());
27098            }
27099    
27100            /**
27101             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
27102             *
27103             * @param groupId the group ID
27104             * @param articleId the article ID
27105             * @param status the status
27106             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27107             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
27108             * @throws SystemException if a system exception occurred
27109             */
27110            @Override
27111            public JournalArticle fetchByG_A_NotST_First(long groupId,
27112                    String articleId, int status, OrderByComparator orderByComparator)
27113                    throws SystemException {
27114                    List<JournalArticle> list = findByG_A_NotST(groupId, articleId, status,
27115                                    0, 1, orderByComparator);
27116    
27117                    if (!list.isEmpty()) {
27118                            return list.get(0);
27119                    }
27120    
27121                    return null;
27122            }
27123    
27124            /**
27125             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
27126             *
27127             * @param groupId the group ID
27128             * @param articleId the article ID
27129             * @param status the status
27130             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27131             * @return the last matching journal article
27132             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
27133             * @throws SystemException if a system exception occurred
27134             */
27135            @Override
27136            public JournalArticle findByG_A_NotST_Last(long groupId, String articleId,
27137                    int status, OrderByComparator orderByComparator)
27138                    throws NoSuchArticleException, SystemException {
27139                    JournalArticle journalArticle = fetchByG_A_NotST_Last(groupId,
27140                                    articleId, status, orderByComparator);
27141    
27142                    if (journalArticle != null) {
27143                            return journalArticle;
27144                    }
27145    
27146                    StringBundler msg = new StringBundler(8);
27147    
27148                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
27149    
27150                    msg.append("groupId=");
27151                    msg.append(groupId);
27152    
27153                    msg.append(", articleId=");
27154                    msg.append(articleId);
27155    
27156                    msg.append(", status=");
27157                    msg.append(status);
27158    
27159                    msg.append(StringPool.CLOSE_CURLY_BRACE);
27160    
27161                    throw new NoSuchArticleException(msg.toString());
27162            }
27163    
27164            /**
27165             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
27166             *
27167             * @param groupId the group ID
27168             * @param articleId the article ID
27169             * @param status the status
27170             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27171             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
27172             * @throws SystemException if a system exception occurred
27173             */
27174            @Override
27175            public JournalArticle fetchByG_A_NotST_Last(long groupId, String articleId,
27176                    int status, OrderByComparator orderByComparator)
27177                    throws SystemException {
27178                    int count = countByG_A_NotST(groupId, articleId, status);
27179    
27180                    if (count == 0) {
27181                            return null;
27182                    }
27183    
27184                    List<JournalArticle> list = findByG_A_NotST(groupId, articleId, status,
27185                                    count - 1, count, orderByComparator);
27186    
27187                    if (!list.isEmpty()) {
27188                            return list.get(0);
27189                    }
27190    
27191                    return null;
27192            }
27193    
27194            /**
27195             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
27196             *
27197             * @param id the primary key of the current journal article
27198             * @param groupId the group ID
27199             * @param articleId the article ID
27200             * @param status the status
27201             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27202             * @return the previous, current, and next journal article
27203             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
27204             * @throws SystemException if a system exception occurred
27205             */
27206            @Override
27207            public JournalArticle[] findByG_A_NotST_PrevAndNext(long id, long groupId,
27208                    String articleId, int status, OrderByComparator orderByComparator)
27209                    throws NoSuchArticleException, SystemException {
27210                    JournalArticle journalArticle = findByPrimaryKey(id);
27211    
27212                    Session session = null;
27213    
27214                    try {
27215                            session = openSession();
27216    
27217                            JournalArticle[] array = new JournalArticleImpl[3];
27218    
27219                            array[0] = getByG_A_NotST_PrevAndNext(session, journalArticle,
27220                                            groupId, articleId, status, orderByComparator, true);
27221    
27222                            array[1] = journalArticle;
27223    
27224                            array[2] = getByG_A_NotST_PrevAndNext(session, journalArticle,
27225                                            groupId, articleId, status, orderByComparator, false);
27226    
27227                            return array;
27228                    }
27229                    catch (Exception e) {
27230                            throw processException(e);
27231                    }
27232                    finally {
27233                            closeSession(session);
27234                    }
27235            }
27236    
27237            protected JournalArticle getByG_A_NotST_PrevAndNext(Session session,
27238                    JournalArticle journalArticle, long groupId, String articleId,
27239                    int status, OrderByComparator orderByComparator, boolean previous) {
27240                    StringBundler query = null;
27241    
27242                    if (orderByComparator != null) {
27243                            query = new StringBundler(6 +
27244                                            (orderByComparator.getOrderByFields().length * 6));
27245                    }
27246                    else {
27247                            query = new StringBundler(3);
27248                    }
27249    
27250                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
27251    
27252                    query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
27253    
27254                    boolean bindArticleId = false;
27255    
27256                    if (articleId == null) {
27257                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
27258                    }
27259                    else if (articleId.equals(StringPool.BLANK)) {
27260                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
27261                    }
27262                    else {
27263                            bindArticleId = true;
27264    
27265                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
27266                    }
27267    
27268                    query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
27269    
27270                    if (orderByComparator != null) {
27271                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
27272    
27273                            if (orderByConditionFields.length > 0) {
27274                                    query.append(WHERE_AND);
27275                            }
27276    
27277                            for (int i = 0; i < orderByConditionFields.length; i++) {
27278                                    query.append(_ORDER_BY_ENTITY_ALIAS);
27279                                    query.append(orderByConditionFields[i]);
27280    
27281                                    if ((i + 1) < orderByConditionFields.length) {
27282                                            if (orderByComparator.isAscending() ^ previous) {
27283                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
27284                                            }
27285                                            else {
27286                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
27287                                            }
27288                                    }
27289                                    else {
27290                                            if (orderByComparator.isAscending() ^ previous) {
27291                                                    query.append(WHERE_GREATER_THAN);
27292                                            }
27293                                            else {
27294                                                    query.append(WHERE_LESSER_THAN);
27295                                            }
27296                                    }
27297                            }
27298    
27299                            query.append(ORDER_BY_CLAUSE);
27300    
27301                            String[] orderByFields = orderByComparator.getOrderByFields();
27302    
27303                            for (int i = 0; i < orderByFields.length; i++) {
27304                                    query.append(_ORDER_BY_ENTITY_ALIAS);
27305                                    query.append(orderByFields[i]);
27306    
27307                                    if ((i + 1) < orderByFields.length) {
27308                                            if (orderByComparator.isAscending() ^ previous) {
27309                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
27310                                            }
27311                                            else {
27312                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
27313                                            }
27314                                    }
27315                                    else {
27316                                            if (orderByComparator.isAscending() ^ previous) {
27317                                                    query.append(ORDER_BY_ASC);
27318                                            }
27319                                            else {
27320                                                    query.append(ORDER_BY_DESC);
27321                                            }
27322                                    }
27323                            }
27324                    }
27325                    else {
27326                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
27327                    }
27328    
27329                    String sql = query.toString();
27330    
27331                    Query q = session.createQuery(sql);
27332    
27333                    q.setFirstResult(0);
27334                    q.setMaxResults(2);
27335    
27336                    QueryPos qPos = QueryPos.getInstance(q);
27337    
27338                    qPos.add(groupId);
27339    
27340                    if (bindArticleId) {
27341                            qPos.add(articleId);
27342                    }
27343    
27344                    qPos.add(status);
27345    
27346                    if (orderByComparator != null) {
27347                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
27348    
27349                            for (Object value : values) {
27350                                    qPos.add(value);
27351                            }
27352                    }
27353    
27354                    List<JournalArticle> list = q.list();
27355    
27356                    if (list.size() == 2) {
27357                            return list.get(1);
27358                    }
27359                    else {
27360                            return null;
27361                    }
27362            }
27363    
27364            /**
27365             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
27366             *
27367             * @param groupId the group ID
27368             * @param articleId the article ID
27369             * @param status the status
27370             * @return the matching journal articles that the user has permission to view
27371             * @throws SystemException if a system exception occurred
27372             */
27373            @Override
27374            public List<JournalArticle> filterFindByG_A_NotST(long groupId,
27375                    String articleId, int status) throws SystemException {
27376                    return filterFindByG_A_NotST(groupId, articleId, status,
27377                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
27378            }
27379    
27380            /**
27381             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
27382             *
27383             * <p>
27384             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
27385             * </p>
27386             *
27387             * @param groupId the group ID
27388             * @param articleId the article ID
27389             * @param status the status
27390             * @param start the lower bound of the range of journal articles
27391             * @param end the upper bound of the range of journal articles (not inclusive)
27392             * @return the range of matching journal articles that the user has permission to view
27393             * @throws SystemException if a system exception occurred
27394             */
27395            @Override
27396            public List<JournalArticle> filterFindByG_A_NotST(long groupId,
27397                    String articleId, int status, int start, int end)
27398                    throws SystemException {
27399                    return filterFindByG_A_NotST(groupId, articleId, status, start, end,
27400                            null);
27401            }
27402    
27403            /**
27404             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
27405             *
27406             * <p>
27407             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
27408             * </p>
27409             *
27410             * @param groupId the group ID
27411             * @param articleId the article ID
27412             * @param status the status
27413             * @param start the lower bound of the range of journal articles
27414             * @param end the upper bound of the range of journal articles (not inclusive)
27415             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
27416             * @return the ordered range of matching journal articles that the user has permission to view
27417             * @throws SystemException if a system exception occurred
27418             */
27419            @Override
27420            public List<JournalArticle> filterFindByG_A_NotST(long groupId,
27421                    String articleId, int status, int start, int end,
27422                    OrderByComparator orderByComparator) throws SystemException {
27423                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
27424                            return findByG_A_NotST(groupId, articleId, status, start, end,
27425                                    orderByComparator);
27426                    }
27427    
27428                    StringBundler query = null;
27429    
27430                    if (orderByComparator != null) {
27431                            query = new StringBundler(5 +
27432                                            (orderByComparator.getOrderByFields().length * 3));
27433                    }
27434                    else {
27435                            query = new StringBundler(5);
27436                    }
27437    
27438                    if (getDB().isSupportsInlineDistinct()) {
27439                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
27440                    }
27441                    else {
27442                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
27443                    }
27444    
27445                    query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
27446    
27447                    boolean bindArticleId = false;
27448    
27449                    if (articleId == null) {
27450                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
27451                    }
27452                    else if (articleId.equals(StringPool.BLANK)) {
27453                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
27454                    }
27455                    else {
27456                            bindArticleId = true;
27457    
27458                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
27459                    }
27460    
27461                    query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
27462    
27463                    if (!getDB().isSupportsInlineDistinct()) {
27464                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
27465                    }
27466    
27467                    if (orderByComparator != null) {
27468                            if (getDB().isSupportsInlineDistinct()) {
27469                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
27470                                            orderByComparator, true);
27471                            }
27472                            else {
27473                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
27474                                            orderByComparator, true);
27475                            }
27476                    }
27477                    else {
27478                            if (getDB().isSupportsInlineDistinct()) {
27479                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
27480                            }
27481                            else {
27482                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
27483                            }
27484                    }
27485    
27486                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
27487                                    JournalArticle.class.getName(),
27488                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
27489    
27490                    Session session = null;
27491    
27492                    try {
27493                            session = openSession();
27494    
27495                            SQLQuery q = session.createSQLQuery(sql);
27496    
27497                            if (getDB().isSupportsInlineDistinct()) {
27498                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
27499                            }
27500                            else {
27501                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
27502                            }
27503    
27504                            QueryPos qPos = QueryPos.getInstance(q);
27505    
27506                            qPos.add(groupId);
27507    
27508                            if (bindArticleId) {
27509                                    qPos.add(articleId);
27510                            }
27511    
27512                            qPos.add(status);
27513    
27514                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
27515                                    end);
27516                    }
27517                    catch (Exception e) {
27518                            throw processException(e);
27519                    }
27520                    finally {
27521                            closeSession(session);
27522                    }
27523            }
27524    
27525            /**
27526             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
27527             *
27528             * @param id the primary key of the current journal article
27529             * @param groupId the group ID
27530             * @param articleId the article ID
27531             * @param status the status
27532             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27533             * @return the previous, current, and next journal article
27534             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
27535             * @throws SystemException if a system exception occurred
27536             */
27537            @Override
27538            public JournalArticle[] filterFindByG_A_NotST_PrevAndNext(long id,
27539                    long groupId, String articleId, int status,
27540                    OrderByComparator orderByComparator)
27541                    throws NoSuchArticleException, SystemException {
27542                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
27543                            return findByG_A_NotST_PrevAndNext(id, groupId, articleId, status,
27544                                    orderByComparator);
27545                    }
27546    
27547                    JournalArticle journalArticle = findByPrimaryKey(id);
27548    
27549                    Session session = null;
27550    
27551                    try {
27552                            session = openSession();
27553    
27554                            JournalArticle[] array = new JournalArticleImpl[3];
27555    
27556                            array[0] = filterGetByG_A_NotST_PrevAndNext(session,
27557                                            journalArticle, groupId, articleId, status,
27558                                            orderByComparator, true);
27559    
27560                            array[1] = journalArticle;
27561    
27562                            array[2] = filterGetByG_A_NotST_PrevAndNext(session,
27563                                            journalArticle, groupId, articleId, status,
27564                                            orderByComparator, false);
27565    
27566                            return array;
27567                    }
27568                    catch (Exception e) {
27569                            throw processException(e);
27570                    }
27571                    finally {
27572                            closeSession(session);
27573                    }
27574            }
27575    
27576            protected JournalArticle filterGetByG_A_NotST_PrevAndNext(Session session,
27577                    JournalArticle journalArticle, long groupId, String articleId,
27578                    int status, OrderByComparator orderByComparator, boolean previous) {
27579                    StringBundler query = null;
27580    
27581                    if (orderByComparator != null) {
27582                            query = new StringBundler(6 +
27583                                            (orderByComparator.getOrderByFields().length * 6));
27584                    }
27585                    else {
27586                            query = new StringBundler(3);
27587                    }
27588    
27589                    if (getDB().isSupportsInlineDistinct()) {
27590                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
27591                    }
27592                    else {
27593                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
27594                    }
27595    
27596                    query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
27597    
27598                    boolean bindArticleId = false;
27599    
27600                    if (articleId == null) {
27601                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
27602                    }
27603                    else if (articleId.equals(StringPool.BLANK)) {
27604                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
27605                    }
27606                    else {
27607                            bindArticleId = true;
27608    
27609                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
27610                    }
27611    
27612                    query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
27613    
27614                    if (!getDB().isSupportsInlineDistinct()) {
27615                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
27616                    }
27617    
27618                    if (orderByComparator != null) {
27619                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
27620    
27621                            if (orderByConditionFields.length > 0) {
27622                                    query.append(WHERE_AND);
27623                            }
27624    
27625                            for (int i = 0; i < orderByConditionFields.length; i++) {
27626                                    if (getDB().isSupportsInlineDistinct()) {
27627                                            query.append(_ORDER_BY_ENTITY_ALIAS);
27628                                    }
27629                                    else {
27630                                            query.append(_ORDER_BY_ENTITY_TABLE);
27631                                    }
27632    
27633                                    query.append(orderByConditionFields[i]);
27634    
27635                                    if ((i + 1) < orderByConditionFields.length) {
27636                                            if (orderByComparator.isAscending() ^ previous) {
27637                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
27638                                            }
27639                                            else {
27640                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
27641                                            }
27642                                    }
27643                                    else {
27644                                            if (orderByComparator.isAscending() ^ previous) {
27645                                                    query.append(WHERE_GREATER_THAN);
27646                                            }
27647                                            else {
27648                                                    query.append(WHERE_LESSER_THAN);
27649                                            }
27650                                    }
27651                            }
27652    
27653                            query.append(ORDER_BY_CLAUSE);
27654    
27655                            String[] orderByFields = orderByComparator.getOrderByFields();
27656    
27657                            for (int i = 0; i < orderByFields.length; i++) {
27658                                    if (getDB().isSupportsInlineDistinct()) {
27659                                            query.append(_ORDER_BY_ENTITY_ALIAS);
27660                                    }
27661                                    else {
27662                                            query.append(_ORDER_BY_ENTITY_TABLE);
27663                                    }
27664    
27665                                    query.append(orderByFields[i]);
27666    
27667                                    if ((i + 1) < orderByFields.length) {
27668                                            if (orderByComparator.isAscending() ^ previous) {
27669                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
27670                                            }
27671                                            else {
27672                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
27673                                            }
27674                                    }
27675                                    else {
27676                                            if (orderByComparator.isAscending() ^ previous) {
27677                                                    query.append(ORDER_BY_ASC);
27678                                            }
27679                                            else {
27680                                                    query.append(ORDER_BY_DESC);
27681                                            }
27682                                    }
27683                            }
27684                    }
27685                    else {
27686                            if (getDB().isSupportsInlineDistinct()) {
27687                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
27688                            }
27689                            else {
27690                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
27691                            }
27692                    }
27693    
27694                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
27695                                    JournalArticle.class.getName(),
27696                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
27697    
27698                    SQLQuery q = session.createSQLQuery(sql);
27699    
27700                    q.setFirstResult(0);
27701                    q.setMaxResults(2);
27702    
27703                    if (getDB().isSupportsInlineDistinct()) {
27704                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
27705                    }
27706                    else {
27707                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
27708                    }
27709    
27710                    QueryPos qPos = QueryPos.getInstance(q);
27711    
27712                    qPos.add(groupId);
27713    
27714                    if (bindArticleId) {
27715                            qPos.add(articleId);
27716                    }
27717    
27718                    qPos.add(status);
27719    
27720                    if (orderByComparator != null) {
27721                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
27722    
27723                            for (Object value : values) {
27724                                    qPos.add(value);
27725                            }
27726                    }
27727    
27728                    List<JournalArticle> list = q.list();
27729    
27730                    if (list.size() == 2) {
27731                            return list.get(1);
27732                    }
27733                    else {
27734                            return null;
27735                    }
27736            }
27737    
27738            /**
27739             * Removes all the journal articles where groupId = &#63; and articleId = &#63; and status &ne; &#63; from the database.
27740             *
27741             * @param groupId the group ID
27742             * @param articleId the article ID
27743             * @param status the status
27744             * @throws SystemException if a system exception occurred
27745             */
27746            @Override
27747            public void removeByG_A_NotST(long groupId, String articleId, int status)
27748                    throws SystemException {
27749                    for (JournalArticle journalArticle : findByG_A_NotST(groupId,
27750                                    articleId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
27751                            remove(journalArticle);
27752                    }
27753            }
27754    
27755            /**
27756             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
27757             *
27758             * @param groupId the group ID
27759             * @param articleId the article ID
27760             * @param status the status
27761             * @return the number of matching journal articles
27762             * @throws SystemException if a system exception occurred
27763             */
27764            @Override
27765            public int countByG_A_NotST(long groupId, String articleId, int status)
27766                    throws SystemException {
27767                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_NOTST;
27768    
27769                    Object[] finderArgs = new Object[] { groupId, articleId, status };
27770    
27771                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
27772                                    this);
27773    
27774                    if (count == null) {
27775                            StringBundler query = new StringBundler(4);
27776    
27777                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
27778    
27779                            query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
27780    
27781                            boolean bindArticleId = false;
27782    
27783                            if (articleId == null) {
27784                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
27785                            }
27786                            else if (articleId.equals(StringPool.BLANK)) {
27787                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
27788                            }
27789                            else {
27790                                    bindArticleId = true;
27791    
27792                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
27793                            }
27794    
27795                            query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
27796    
27797                            String sql = query.toString();
27798    
27799                            Session session = null;
27800    
27801                            try {
27802                                    session = openSession();
27803    
27804                                    Query q = session.createQuery(sql);
27805    
27806                                    QueryPos qPos = QueryPos.getInstance(q);
27807    
27808                                    qPos.add(groupId);
27809    
27810                                    if (bindArticleId) {
27811                                            qPos.add(articleId);
27812                                    }
27813    
27814                                    qPos.add(status);
27815    
27816                                    count = (Long)q.uniqueResult();
27817    
27818                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
27819                            }
27820                            catch (Exception e) {
27821                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
27822    
27823                                    throw processException(e);
27824                            }
27825                            finally {
27826                                    closeSession(session);
27827                            }
27828                    }
27829    
27830                    return count.intValue();
27831            }
27832    
27833            /**
27834             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
27835             *
27836             * @param groupId the group ID
27837             * @param articleId the article ID
27838             * @param status the status
27839             * @return the number of matching journal articles that the user has permission to view
27840             * @throws SystemException if a system exception occurred
27841             */
27842            @Override
27843            public int filterCountByG_A_NotST(long groupId, String articleId, int status)
27844                    throws SystemException {
27845                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
27846                            return countByG_A_NotST(groupId, articleId, status);
27847                    }
27848    
27849                    StringBundler query = new StringBundler(4);
27850    
27851                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
27852    
27853                    query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
27854    
27855                    boolean bindArticleId = false;
27856    
27857                    if (articleId == null) {
27858                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
27859                    }
27860                    else if (articleId.equals(StringPool.BLANK)) {
27861                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
27862                    }
27863                    else {
27864                            bindArticleId = true;
27865    
27866                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
27867                    }
27868    
27869                    query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
27870    
27871                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
27872                                    JournalArticle.class.getName(),
27873                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
27874    
27875                    Session session = null;
27876    
27877                    try {
27878                            session = openSession();
27879    
27880                            SQLQuery q = session.createSQLQuery(sql);
27881    
27882                            q.addScalar(COUNT_COLUMN_NAME,
27883                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
27884    
27885                            QueryPos qPos = QueryPos.getInstance(q);
27886    
27887                            qPos.add(groupId);
27888    
27889                            if (bindArticleId) {
27890                                    qPos.add(articleId);
27891                            }
27892    
27893                            qPos.add(status);
27894    
27895                            Long count = (Long)q.uniqueResult();
27896    
27897                            return count.intValue();
27898                    }
27899                    catch (Exception e) {
27900                            throw processException(e);
27901                    }
27902                    finally {
27903                            closeSession(session);
27904                    }
27905            }
27906    
27907            private static final String _FINDER_COLUMN_G_A_NOTST_GROUPID_2 = "journalArticle.groupId = ? AND ";
27908            private static final String _FINDER_COLUMN_G_A_NOTST_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
27909            private static final String _FINDER_COLUMN_G_A_NOTST_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
27910            private static final String _FINDER_COLUMN_G_A_NOTST_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '') AND ";
27911            private static final String _FINDER_COLUMN_G_A_NOTST_STATUS_2 = "journalArticle.status != ?";
27912            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
27913                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
27914                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
27915                            "findByG_UT_ST",
27916                            new String[] {
27917                                    Long.class.getName(), String.class.getName(),
27918                                    Integer.class.getName(),
27919                                    
27920                            Integer.class.getName(), Integer.class.getName(),
27921                                    OrderByComparator.class.getName()
27922                            });
27923            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST =
27924                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
27925                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
27926                            JournalArticleImpl.class,
27927                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_UT_ST",
27928                            new String[] {
27929                                    Long.class.getName(), String.class.getName(),
27930                                    Integer.class.getName()
27931                            },
27932                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
27933                            JournalArticleModelImpl.URLTITLE_COLUMN_BITMASK |
27934                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
27935                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
27936                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
27937            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
27938                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
27939                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT_ST",
27940                            new String[] {
27941                                    Long.class.getName(), String.class.getName(),
27942                                    Integer.class.getName()
27943                            });
27944    
27945            /**
27946             * Returns all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27947             *
27948             * @param groupId the group ID
27949             * @param urlTitle the url title
27950             * @param status the status
27951             * @return the matching journal articles
27952             * @throws SystemException if a system exception occurred
27953             */
27954            @Override
27955            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
27956                    int status) throws SystemException {
27957                    return findByG_UT_ST(groupId, urlTitle, status, QueryUtil.ALL_POS,
27958                            QueryUtil.ALL_POS, null);
27959            }
27960    
27961            /**
27962             * Returns a range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27963             *
27964             * <p>
27965             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
27966             * </p>
27967             *
27968             * @param groupId the group ID
27969             * @param urlTitle the url title
27970             * @param status the status
27971             * @param start the lower bound of the range of journal articles
27972             * @param end the upper bound of the range of journal articles (not inclusive)
27973             * @return the range of matching journal articles
27974             * @throws SystemException if a system exception occurred
27975             */
27976            @Override
27977            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
27978                    int status, int start, int end) throws SystemException {
27979                    return findByG_UT_ST(groupId, urlTitle, status, start, end, null);
27980            }
27981    
27982            /**
27983             * Returns an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27984             *
27985             * <p>
27986             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
27987             * </p>
27988             *
27989             * @param groupId the group ID
27990             * @param urlTitle the url title
27991             * @param status the status
27992             * @param start the lower bound of the range of journal articles
27993             * @param end the upper bound of the range of journal articles (not inclusive)
27994             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
27995             * @return the ordered range of matching journal articles
27996             * @throws SystemException if a system exception occurred
27997             */
27998            @Override
27999            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
28000                    int status, int start, int end, OrderByComparator orderByComparator)
28001                    throws SystemException {
28002                    boolean pagination = true;
28003                    FinderPath finderPath = null;
28004                    Object[] finderArgs = null;
28005    
28006                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
28007                                    (orderByComparator == null)) {
28008                            pagination = false;
28009                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST;
28010                            finderArgs = new Object[] { groupId, urlTitle, status };
28011                    }
28012                    else {
28013                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT_ST;
28014                            finderArgs = new Object[] {
28015                                            groupId, urlTitle, status,
28016                                            
28017                                            start, end, orderByComparator
28018                                    };
28019                    }
28020    
28021                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
28022                                    finderArgs, this);
28023    
28024                    if ((list != null) && !list.isEmpty()) {
28025                            for (JournalArticle journalArticle : list) {
28026                                    if ((groupId != journalArticle.getGroupId()) ||
28027                                                    !Validator.equals(urlTitle, journalArticle.getUrlTitle()) ||
28028                                                    (status != journalArticle.getStatus())) {
28029                                            list = null;
28030    
28031                                            break;
28032                                    }
28033                            }
28034                    }
28035    
28036                    if (list == null) {
28037                            StringBundler query = null;
28038    
28039                            if (orderByComparator != null) {
28040                                    query = new StringBundler(5 +
28041                                                    (orderByComparator.getOrderByFields().length * 3));
28042                            }
28043                            else {
28044                                    query = new StringBundler(5);
28045                            }
28046    
28047                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
28048    
28049                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
28050    
28051                            boolean bindUrlTitle = false;
28052    
28053                            if (urlTitle == null) {
28054                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
28055                            }
28056                            else if (urlTitle.equals(StringPool.BLANK)) {
28057                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
28058                            }
28059                            else {
28060                                    bindUrlTitle = true;
28061    
28062                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
28063                            }
28064    
28065                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
28066    
28067                            if (orderByComparator != null) {
28068                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
28069                                            orderByComparator);
28070                            }
28071                            else
28072                             if (pagination) {
28073                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
28074                            }
28075    
28076                            String sql = query.toString();
28077    
28078                            Session session = null;
28079    
28080                            try {
28081                                    session = openSession();
28082    
28083                                    Query q = session.createQuery(sql);
28084    
28085                                    QueryPos qPos = QueryPos.getInstance(q);
28086    
28087                                    qPos.add(groupId);
28088    
28089                                    if (bindUrlTitle) {
28090                                            qPos.add(urlTitle);
28091                                    }
28092    
28093                                    qPos.add(status);
28094    
28095                                    if (!pagination) {
28096                                            list = (List<JournalArticle>)QueryUtil.list(q,
28097                                                            getDialect(), start, end, false);
28098    
28099                                            Collections.sort(list);
28100    
28101                                            list = new UnmodifiableList<JournalArticle>(list);
28102                                    }
28103                                    else {
28104                                            list = (List<JournalArticle>)QueryUtil.list(q,
28105                                                            getDialect(), start, end);
28106                                    }
28107    
28108                                    cacheResult(list);
28109    
28110                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
28111                            }
28112                            catch (Exception e) {
28113                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
28114    
28115                                    throw processException(e);
28116                            }
28117                            finally {
28118                                    closeSession(session);
28119                            }
28120                    }
28121    
28122                    return list;
28123            }
28124    
28125            /**
28126             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
28127             *
28128             * @param groupId the group ID
28129             * @param urlTitle the url title
28130             * @param status the status
28131             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
28132             * @return the first matching journal article
28133             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
28134             * @throws SystemException if a system exception occurred
28135             */
28136            @Override
28137            public JournalArticle findByG_UT_ST_First(long groupId, String urlTitle,
28138                    int status, OrderByComparator orderByComparator)
28139                    throws NoSuchArticleException, SystemException {
28140                    JournalArticle journalArticle = fetchByG_UT_ST_First(groupId, urlTitle,
28141                                    status, orderByComparator);
28142    
28143                    if (journalArticle != null) {
28144                            return journalArticle;
28145                    }
28146    
28147                    StringBundler msg = new StringBundler(8);
28148    
28149                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
28150    
28151                    msg.append("groupId=");
28152                    msg.append(groupId);
28153    
28154                    msg.append(", urlTitle=");
28155                    msg.append(urlTitle);
28156    
28157                    msg.append(", status=");
28158                    msg.append(status);
28159    
28160                    msg.append(StringPool.CLOSE_CURLY_BRACE);
28161    
28162                    throw new NoSuchArticleException(msg.toString());
28163            }
28164    
28165            /**
28166             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
28167             *
28168             * @param groupId the group ID
28169             * @param urlTitle the url title
28170             * @param status the status
28171             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
28172             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
28173             * @throws SystemException if a system exception occurred
28174             */
28175            @Override
28176            public JournalArticle fetchByG_UT_ST_First(long groupId, String urlTitle,
28177                    int status, OrderByComparator orderByComparator)
28178                    throws SystemException {
28179                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status, 0,
28180                                    1, orderByComparator);
28181    
28182                    if (!list.isEmpty()) {
28183                            return list.get(0);
28184                    }
28185    
28186                    return null;
28187            }
28188    
28189            /**
28190             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
28191             *
28192             * @param groupId the group ID
28193             * @param urlTitle the url title
28194             * @param status the status
28195             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
28196             * @return the last matching journal article
28197             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
28198             * @throws SystemException if a system exception occurred
28199             */
28200            @Override
28201            public JournalArticle findByG_UT_ST_Last(long groupId, String urlTitle,
28202                    int status, OrderByComparator orderByComparator)
28203                    throws NoSuchArticleException, SystemException {
28204                    JournalArticle journalArticle = fetchByG_UT_ST_Last(groupId, urlTitle,
28205                                    status, orderByComparator);
28206    
28207                    if (journalArticle != null) {
28208                            return journalArticle;
28209                    }
28210    
28211                    StringBundler msg = new StringBundler(8);
28212    
28213                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
28214    
28215                    msg.append("groupId=");
28216                    msg.append(groupId);
28217    
28218                    msg.append(", urlTitle=");
28219                    msg.append(urlTitle);
28220    
28221                    msg.append(", status=");
28222                    msg.append(status);
28223    
28224                    msg.append(StringPool.CLOSE_CURLY_BRACE);
28225    
28226                    throw new NoSuchArticleException(msg.toString());
28227            }
28228    
28229            /**
28230             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
28231             *
28232             * @param groupId the group ID
28233             * @param urlTitle the url title
28234             * @param status the status
28235             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
28236             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
28237             * @throws SystemException if a system exception occurred
28238             */
28239            @Override
28240            public JournalArticle fetchByG_UT_ST_Last(long groupId, String urlTitle,
28241                    int status, OrderByComparator orderByComparator)
28242                    throws SystemException {
28243                    int count = countByG_UT_ST(groupId, urlTitle, status);
28244    
28245                    if (count == 0) {
28246                            return null;
28247                    }
28248    
28249                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status,
28250                                    count - 1, count, orderByComparator);
28251    
28252                    if (!list.isEmpty()) {
28253                            return list.get(0);
28254                    }
28255    
28256                    return null;
28257            }
28258    
28259            /**
28260             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
28261             *
28262             * @param id the primary key of the current journal article
28263             * @param groupId the group ID
28264             * @param urlTitle the url title
28265             * @param status the status
28266             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
28267             * @return the previous, current, and next journal article
28268             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
28269             * @throws SystemException if a system exception occurred
28270             */
28271            @Override
28272            public JournalArticle[] findByG_UT_ST_PrevAndNext(long id, long groupId,
28273                    String urlTitle, int status, OrderByComparator orderByComparator)
28274                    throws NoSuchArticleException, SystemException {
28275                    JournalArticle journalArticle = findByPrimaryKey(id);
28276    
28277                    Session session = null;
28278    
28279                    try {
28280                            session = openSession();
28281    
28282                            JournalArticle[] array = new JournalArticleImpl[3];
28283    
28284                            array[0] = getByG_UT_ST_PrevAndNext(session, journalArticle,
28285                                            groupId, urlTitle, status, orderByComparator, true);
28286    
28287                            array[1] = journalArticle;
28288    
28289                            array[2] = getByG_UT_ST_PrevAndNext(session, journalArticle,
28290                                            groupId, urlTitle, status, orderByComparator, false);
28291    
28292                            return array;
28293                    }
28294                    catch (Exception e) {
28295                            throw processException(e);
28296                    }
28297                    finally {
28298                            closeSession(session);
28299                    }
28300            }
28301    
28302            protected JournalArticle getByG_UT_ST_PrevAndNext(Session session,
28303                    JournalArticle journalArticle, long groupId, String urlTitle,
28304                    int status, OrderByComparator orderByComparator, boolean previous) {
28305                    StringBundler query = null;
28306    
28307                    if (orderByComparator != null) {
28308                            query = new StringBundler(6 +
28309                                            (orderByComparator.getOrderByFields().length * 6));
28310                    }
28311                    else {
28312                            query = new StringBundler(3);
28313                    }
28314    
28315                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
28316    
28317                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
28318    
28319                    boolean bindUrlTitle = false;
28320    
28321                    if (urlTitle == null) {
28322                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
28323                    }
28324                    else if (urlTitle.equals(StringPool.BLANK)) {
28325                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
28326                    }
28327                    else {
28328                            bindUrlTitle = true;
28329    
28330                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
28331                    }
28332    
28333                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
28334    
28335                    if (orderByComparator != null) {
28336                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
28337    
28338                            if (orderByConditionFields.length > 0) {
28339                                    query.append(WHERE_AND);
28340                            }
28341    
28342                            for (int i = 0; i < orderByConditionFields.length; i++) {
28343                                    query.append(_ORDER_BY_ENTITY_ALIAS);
28344                                    query.append(orderByConditionFields[i]);
28345    
28346                                    if ((i + 1) < orderByConditionFields.length) {
28347                                            if (orderByComparator.isAscending() ^ previous) {
28348                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
28349                                            }
28350                                            else {
28351                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
28352                                            }
28353                                    }
28354                                    else {
28355                                            if (orderByComparator.isAscending() ^ previous) {
28356                                                    query.append(WHERE_GREATER_THAN);
28357                                            }
28358                                            else {
28359                                                    query.append(WHERE_LESSER_THAN);
28360                                            }
28361                                    }
28362                            }
28363    
28364                            query.append(ORDER_BY_CLAUSE);
28365    
28366                            String[] orderByFields = orderByComparator.getOrderByFields();
28367    
28368                            for (int i = 0; i < orderByFields.length; i++) {
28369                                    query.append(_ORDER_BY_ENTITY_ALIAS);
28370                                    query.append(orderByFields[i]);
28371    
28372                                    if ((i + 1) < orderByFields.length) {
28373                                            if (orderByComparator.isAscending() ^ previous) {
28374                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
28375                                            }
28376                                            else {
28377                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
28378                                            }
28379                                    }
28380                                    else {
28381                                            if (orderByComparator.isAscending() ^ previous) {
28382                                                    query.append(ORDER_BY_ASC);
28383                                            }
28384                                            else {
28385                                                    query.append(ORDER_BY_DESC);
28386                                            }
28387                                    }
28388                            }
28389                    }
28390                    else {
28391                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
28392                    }
28393    
28394                    String sql = query.toString();
28395    
28396                    Query q = session.createQuery(sql);
28397    
28398                    q.setFirstResult(0);
28399                    q.setMaxResults(2);
28400    
28401                    QueryPos qPos = QueryPos.getInstance(q);
28402    
28403                    qPos.add(groupId);
28404    
28405                    if (bindUrlTitle) {
28406                            qPos.add(urlTitle);
28407                    }
28408    
28409                    qPos.add(status);
28410    
28411                    if (orderByComparator != null) {
28412                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
28413    
28414                            for (Object value : values) {
28415                                    qPos.add(value);
28416                            }
28417                    }
28418    
28419                    List<JournalArticle> list = q.list();
28420    
28421                    if (list.size() == 2) {
28422                            return list.get(1);
28423                    }
28424                    else {
28425                            return null;
28426                    }
28427            }
28428    
28429            /**
28430             * Returns all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
28431             *
28432             * @param groupId the group ID
28433             * @param urlTitle the url title
28434             * @param status the status
28435             * @return the matching journal articles that the user has permission to view
28436             * @throws SystemException if a system exception occurred
28437             */
28438            @Override
28439            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
28440                    String urlTitle, int status) throws SystemException {
28441                    return filterFindByG_UT_ST(groupId, urlTitle, status,
28442                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
28443            }
28444    
28445            /**
28446             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
28447             *
28448             * <p>
28449             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
28450             * </p>
28451             *
28452             * @param groupId the group ID
28453             * @param urlTitle the url title
28454             * @param status the status
28455             * @param start the lower bound of the range of journal articles
28456             * @param end the upper bound of the range of journal articles (not inclusive)
28457             * @return the range of matching journal articles that the user has permission to view
28458             * @throws SystemException if a system exception occurred
28459             */
28460            @Override
28461            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
28462                    String urlTitle, int status, int start, int end)
28463                    throws SystemException {
28464                    return filterFindByG_UT_ST(groupId, urlTitle, status, start, end, null);
28465            }
28466    
28467            /**
28468             * 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;.
28469             *
28470             * <p>
28471             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
28472             * </p>
28473             *
28474             * @param groupId the group ID
28475             * @param urlTitle the url title
28476             * @param status the status
28477             * @param start the lower bound of the range of journal articles
28478             * @param end the upper bound of the range of journal articles (not inclusive)
28479             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
28480             * @return the ordered range of matching journal articles that the user has permission to view
28481             * @throws SystemException if a system exception occurred
28482             */
28483            @Override
28484            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
28485                    String urlTitle, int status, int start, int end,
28486                    OrderByComparator orderByComparator) throws SystemException {
28487                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
28488                            return findByG_UT_ST(groupId, urlTitle, status, start, end,
28489                                    orderByComparator);
28490                    }
28491    
28492                    StringBundler query = null;
28493    
28494                    if (orderByComparator != null) {
28495                            query = new StringBundler(5 +
28496                                            (orderByComparator.getOrderByFields().length * 3));
28497                    }
28498                    else {
28499                            query = new StringBundler(5);
28500                    }
28501    
28502                    if (getDB().isSupportsInlineDistinct()) {
28503                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
28504                    }
28505                    else {
28506                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
28507                    }
28508    
28509                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
28510    
28511                    boolean bindUrlTitle = false;
28512    
28513                    if (urlTitle == null) {
28514                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
28515                    }
28516                    else if (urlTitle.equals(StringPool.BLANK)) {
28517                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
28518                    }
28519                    else {
28520                            bindUrlTitle = true;
28521    
28522                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
28523                    }
28524    
28525                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
28526    
28527                    if (!getDB().isSupportsInlineDistinct()) {
28528                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
28529                    }
28530    
28531                    if (orderByComparator != null) {
28532                            if (getDB().isSupportsInlineDistinct()) {
28533                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
28534                                            orderByComparator, true);
28535                            }
28536                            else {
28537                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
28538                                            orderByComparator, true);
28539                            }
28540                    }
28541                    else {
28542                            if (getDB().isSupportsInlineDistinct()) {
28543                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
28544                            }
28545                            else {
28546                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
28547                            }
28548                    }
28549    
28550                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
28551                                    JournalArticle.class.getName(),
28552                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
28553    
28554                    Session session = null;
28555    
28556                    try {
28557                            session = openSession();
28558    
28559                            SQLQuery q = session.createSQLQuery(sql);
28560    
28561                            if (getDB().isSupportsInlineDistinct()) {
28562                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
28563                            }
28564                            else {
28565                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
28566                            }
28567    
28568                            QueryPos qPos = QueryPos.getInstance(q);
28569    
28570                            qPos.add(groupId);
28571    
28572                            if (bindUrlTitle) {
28573                                    qPos.add(urlTitle);
28574                            }
28575    
28576                            qPos.add(status);
28577    
28578                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
28579                                    end);
28580                    }
28581                    catch (Exception e) {
28582                            throw processException(e);
28583                    }
28584                    finally {
28585                            closeSession(session);
28586                    }
28587            }
28588    
28589            /**
28590             * 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;.
28591             *
28592             * @param id the primary key of the current journal article
28593             * @param groupId the group ID
28594             * @param urlTitle the url title
28595             * @param status the status
28596             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
28597             * @return the previous, current, and next journal article
28598             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
28599             * @throws SystemException if a system exception occurred
28600             */
28601            @Override
28602            public JournalArticle[] filterFindByG_UT_ST_PrevAndNext(long id,
28603                    long groupId, String urlTitle, int status,
28604                    OrderByComparator orderByComparator)
28605                    throws NoSuchArticleException, SystemException {
28606                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
28607                            return findByG_UT_ST_PrevAndNext(id, groupId, urlTitle, status,
28608                                    orderByComparator);
28609                    }
28610    
28611                    JournalArticle journalArticle = findByPrimaryKey(id);
28612    
28613                    Session session = null;
28614    
28615                    try {
28616                            session = openSession();
28617    
28618                            JournalArticle[] array = new JournalArticleImpl[3];
28619    
28620                            array[0] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
28621                                            groupId, urlTitle, status, orderByComparator, true);
28622    
28623                            array[1] = journalArticle;
28624    
28625                            array[2] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
28626                                            groupId, urlTitle, status, orderByComparator, false);
28627    
28628                            return array;
28629                    }
28630                    catch (Exception e) {
28631                            throw processException(e);
28632                    }
28633                    finally {
28634                            closeSession(session);
28635                    }
28636            }
28637    
28638            protected JournalArticle filterGetByG_UT_ST_PrevAndNext(Session session,
28639                    JournalArticle journalArticle, long groupId, String urlTitle,
28640                    int status, OrderByComparator orderByComparator, boolean previous) {
28641                    StringBundler query = null;
28642    
28643                    if (orderByComparator != null) {
28644                            query = new StringBundler(6 +
28645                                            (orderByComparator.getOrderByFields().length * 6));
28646                    }
28647                    else {
28648                            query = new StringBundler(3);
28649                    }
28650    
28651                    if (getDB().isSupportsInlineDistinct()) {
28652                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
28653                    }
28654                    else {
28655                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
28656                    }
28657    
28658                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
28659    
28660                    boolean bindUrlTitle = false;
28661    
28662                    if (urlTitle == null) {
28663                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
28664                    }
28665                    else if (urlTitle.equals(StringPool.BLANK)) {
28666                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
28667                    }
28668                    else {
28669                            bindUrlTitle = true;
28670    
28671                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
28672                    }
28673    
28674                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
28675    
28676                    if (!getDB().isSupportsInlineDistinct()) {
28677                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
28678                    }
28679    
28680                    if (orderByComparator != null) {
28681                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
28682    
28683                            if (orderByConditionFields.length > 0) {
28684                                    query.append(WHERE_AND);
28685                            }
28686    
28687                            for (int i = 0; i < orderByConditionFields.length; i++) {
28688                                    if (getDB().isSupportsInlineDistinct()) {
28689                                            query.append(_ORDER_BY_ENTITY_ALIAS);
28690                                    }
28691                                    else {
28692                                            query.append(_ORDER_BY_ENTITY_TABLE);
28693                                    }
28694    
28695                                    query.append(orderByConditionFields[i]);
28696    
28697                                    if ((i + 1) < orderByConditionFields.length) {
28698                                            if (orderByComparator.isAscending() ^ previous) {
28699                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
28700                                            }
28701                                            else {
28702                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
28703                                            }
28704                                    }
28705                                    else {
28706                                            if (orderByComparator.isAscending() ^ previous) {
28707                                                    query.append(WHERE_GREATER_THAN);
28708                                            }
28709                                            else {
28710                                                    query.append(WHERE_LESSER_THAN);
28711                                            }
28712                                    }
28713                            }
28714    
28715                            query.append(ORDER_BY_CLAUSE);
28716    
28717                            String[] orderByFields = orderByComparator.getOrderByFields();
28718    
28719                            for (int i = 0; i < orderByFields.length; i++) {
28720                                    if (getDB().isSupportsInlineDistinct()) {
28721                                            query.append(_ORDER_BY_ENTITY_ALIAS);
28722                                    }
28723                                    else {
28724                                            query.append(_ORDER_BY_ENTITY_TABLE);
28725                                    }
28726    
28727                                    query.append(orderByFields[i]);
28728    
28729                                    if ((i + 1) < orderByFields.length) {
28730                                            if (orderByComparator.isAscending() ^ previous) {
28731                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
28732                                            }
28733                                            else {
28734                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
28735                                            }
28736                                    }
28737                                    else {
28738                                            if (orderByComparator.isAscending() ^ previous) {
28739                                                    query.append(ORDER_BY_ASC);
28740                                            }
28741                                            else {
28742                                                    query.append(ORDER_BY_DESC);
28743                                            }
28744                                    }
28745                            }
28746                    }
28747                    else {
28748                            if (getDB().isSupportsInlineDistinct()) {
28749                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
28750                            }
28751                            else {
28752                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
28753                            }
28754                    }
28755    
28756                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
28757                                    JournalArticle.class.getName(),
28758                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
28759    
28760                    SQLQuery q = session.createSQLQuery(sql);
28761    
28762                    q.setFirstResult(0);
28763                    q.setMaxResults(2);
28764    
28765                    if (getDB().isSupportsInlineDistinct()) {
28766                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
28767                    }
28768                    else {
28769                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
28770                    }
28771    
28772                    QueryPos qPos = QueryPos.getInstance(q);
28773    
28774                    qPos.add(groupId);
28775    
28776                    if (bindUrlTitle) {
28777                            qPos.add(urlTitle);
28778                    }
28779    
28780                    qPos.add(status);
28781    
28782                    if (orderByComparator != null) {
28783                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
28784    
28785                            for (Object value : values) {
28786                                    qPos.add(value);
28787                            }
28788                    }
28789    
28790                    List<JournalArticle> list = q.list();
28791    
28792                    if (list.size() == 2) {
28793                            return list.get(1);
28794                    }
28795                    else {
28796                            return null;
28797                    }
28798            }
28799    
28800            /**
28801             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63; from the database.
28802             *
28803             * @param groupId the group ID
28804             * @param urlTitle the url title
28805             * @param status the status
28806             * @throws SystemException if a system exception occurred
28807             */
28808            @Override
28809            public void removeByG_UT_ST(long groupId, String urlTitle, int status)
28810                    throws SystemException {
28811                    for (JournalArticle journalArticle : findByG_UT_ST(groupId, urlTitle,
28812                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
28813                            remove(journalArticle);
28814                    }
28815            }
28816    
28817            /**
28818             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
28819             *
28820             * @param groupId the group ID
28821             * @param urlTitle the url title
28822             * @param status the status
28823             * @return the number of matching journal articles
28824             * @throws SystemException if a system exception occurred
28825             */
28826            @Override
28827            public int countByG_UT_ST(long groupId, String urlTitle, int status)
28828                    throws SystemException {
28829                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_UT_ST;
28830    
28831                    Object[] finderArgs = new Object[] { groupId, urlTitle, status };
28832    
28833                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
28834                                    this);
28835    
28836                    if (count == null) {
28837                            StringBundler query = new StringBundler(4);
28838    
28839                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
28840    
28841                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
28842    
28843                            boolean bindUrlTitle = false;
28844    
28845                            if (urlTitle == null) {
28846                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
28847                            }
28848                            else if (urlTitle.equals(StringPool.BLANK)) {
28849                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
28850                            }
28851                            else {
28852                                    bindUrlTitle = true;
28853    
28854                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
28855                            }
28856    
28857                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
28858    
28859                            String sql = query.toString();
28860    
28861                            Session session = null;
28862    
28863                            try {
28864                                    session = openSession();
28865    
28866                                    Query q = session.createQuery(sql);
28867    
28868                                    QueryPos qPos = QueryPos.getInstance(q);
28869    
28870                                    qPos.add(groupId);
28871    
28872                                    if (bindUrlTitle) {
28873                                            qPos.add(urlTitle);
28874                                    }
28875    
28876                                    qPos.add(status);
28877    
28878                                    count = (Long)q.uniqueResult();
28879    
28880                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
28881                            }
28882                            catch (Exception e) {
28883                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
28884    
28885                                    throw processException(e);
28886                            }
28887                            finally {
28888                                    closeSession(session);
28889                            }
28890                    }
28891    
28892                    return count.intValue();
28893            }
28894    
28895            /**
28896             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
28897             *
28898             * @param groupId the group ID
28899             * @param urlTitle the url title
28900             * @param status the status
28901             * @return the number of matching journal articles that the user has permission to view
28902             * @throws SystemException if a system exception occurred
28903             */
28904            @Override
28905            public int filterCountByG_UT_ST(long groupId, String urlTitle, int status)
28906                    throws SystemException {
28907                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
28908                            return countByG_UT_ST(groupId, urlTitle, status);
28909                    }
28910    
28911                    StringBundler query = new StringBundler(4);
28912    
28913                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
28914    
28915                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
28916    
28917                    boolean bindUrlTitle = false;
28918    
28919                    if (urlTitle == null) {
28920                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
28921                    }
28922                    else if (urlTitle.equals(StringPool.BLANK)) {
28923                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
28924                    }
28925                    else {
28926                            bindUrlTitle = true;
28927    
28928                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
28929                    }
28930    
28931                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
28932    
28933                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
28934                                    JournalArticle.class.getName(),
28935                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
28936    
28937                    Session session = null;
28938    
28939                    try {
28940                            session = openSession();
28941    
28942                            SQLQuery q = session.createSQLQuery(sql);
28943    
28944                            q.addScalar(COUNT_COLUMN_NAME,
28945                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
28946    
28947                            QueryPos qPos = QueryPos.getInstance(q);
28948    
28949                            qPos.add(groupId);
28950    
28951                            if (bindUrlTitle) {
28952                                    qPos.add(urlTitle);
28953                            }
28954    
28955                            qPos.add(status);
28956    
28957                            Long count = (Long)q.uniqueResult();
28958    
28959                            return count.intValue();
28960                    }
28961                    catch (Exception e) {
28962                            throw processException(e);
28963                    }
28964                    finally {
28965                            closeSession(session);
28966                    }
28967            }
28968    
28969            private static final String _FINDER_COLUMN_G_UT_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
28970            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_1 = "journalArticle.urlTitle IS NULL AND ";
28971            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_2 = "journalArticle.urlTitle = ? AND ";
28972            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = '') AND ";
28973            private static final String _FINDER_COLUMN_G_UT_ST_STATUS_2 = "journalArticle.status = ?";
28974            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
28975                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
28976                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
28977                            "findByC_V_ST",
28978                            new String[] {
28979                                    Long.class.getName(), Double.class.getName(),
28980                                    Integer.class.getName(),
28981                                    
28982                            Integer.class.getName(), Integer.class.getName(),
28983                                    OrderByComparator.class.getName()
28984                            });
28985            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST =
28986                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
28987                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
28988                            JournalArticleImpl.class,
28989                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_V_ST",
28990                            new String[] {
28991                                    Long.class.getName(), Double.class.getName(),
28992                                    Integer.class.getName()
28993                            },
28994                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
28995                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK |
28996                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
28997                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK);
28998            public static final FinderPath FINDER_PATH_COUNT_BY_C_V_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
28999                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
29000                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_V_ST",
29001                            new String[] {
29002                                    Long.class.getName(), Double.class.getName(),
29003                                    Integer.class.getName()
29004                            });
29005    
29006            /**
29007             * Returns all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
29008             *
29009             * @param companyId the company ID
29010             * @param version the version
29011             * @param status the status
29012             * @return the matching journal articles
29013             * @throws SystemException if a system exception occurred
29014             */
29015            @Override
29016            public List<JournalArticle> findByC_V_ST(long companyId, double version,
29017                    int status) throws SystemException {
29018                    return findByC_V_ST(companyId, version, status, QueryUtil.ALL_POS,
29019                            QueryUtil.ALL_POS, null);
29020            }
29021    
29022            /**
29023             * Returns a range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
29024             *
29025             * <p>
29026             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
29027             * </p>
29028             *
29029             * @param companyId the company ID
29030             * @param version the version
29031             * @param status the status
29032             * @param start the lower bound of the range of journal articles
29033             * @param end the upper bound of the range of journal articles (not inclusive)
29034             * @return the range of matching journal articles
29035             * @throws SystemException if a system exception occurred
29036             */
29037            @Override
29038            public List<JournalArticle> findByC_V_ST(long companyId, double version,
29039                    int status, int start, int end) throws SystemException {
29040                    return findByC_V_ST(companyId, version, status, start, end, null);
29041            }
29042    
29043            /**
29044             * Returns an ordered range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
29045             *
29046             * <p>
29047             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
29048             * </p>
29049             *
29050             * @param companyId the company ID
29051             * @param version the version
29052             * @param status the status
29053             * @param start the lower bound of the range of journal articles
29054             * @param end the upper bound of the range of journal articles (not inclusive)
29055             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
29056             * @return the ordered range of matching journal articles
29057             * @throws SystemException if a system exception occurred
29058             */
29059            @Override
29060            public List<JournalArticle> findByC_V_ST(long companyId, double version,
29061                    int status, int start, int end, OrderByComparator orderByComparator)
29062                    throws SystemException {
29063                    boolean pagination = true;
29064                    FinderPath finderPath = null;
29065                    Object[] finderArgs = null;
29066    
29067                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
29068                                    (orderByComparator == null)) {
29069                            pagination = false;
29070                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST;
29071                            finderArgs = new Object[] { companyId, version, status };
29072                    }
29073                    else {
29074                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V_ST;
29075                            finderArgs = new Object[] {
29076                                            companyId, version, status,
29077                                            
29078                                            start, end, orderByComparator
29079                                    };
29080                    }
29081    
29082                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
29083                                    finderArgs, this);
29084    
29085                    if ((list != null) && !list.isEmpty()) {
29086                            for (JournalArticle journalArticle : list) {
29087                                    if ((companyId != journalArticle.getCompanyId()) ||
29088                                                    (version != journalArticle.getVersion()) ||
29089                                                    (status != journalArticle.getStatus())) {
29090                                            list = null;
29091    
29092                                            break;
29093                                    }
29094                            }
29095                    }
29096    
29097                    if (list == null) {
29098                            StringBundler query = null;
29099    
29100                            if (orderByComparator != null) {
29101                                    query = new StringBundler(5 +
29102                                                    (orderByComparator.getOrderByFields().length * 3));
29103                            }
29104                            else {
29105                                    query = new StringBundler(5);
29106                            }
29107    
29108                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
29109    
29110                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
29111    
29112                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
29113    
29114                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
29115    
29116                            if (orderByComparator != null) {
29117                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
29118                                            orderByComparator);
29119                            }
29120                            else
29121                             if (pagination) {
29122                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
29123                            }
29124    
29125                            String sql = query.toString();
29126    
29127                            Session session = null;
29128    
29129                            try {
29130                                    session = openSession();
29131    
29132                                    Query q = session.createQuery(sql);
29133    
29134                                    QueryPos qPos = QueryPos.getInstance(q);
29135    
29136                                    qPos.add(companyId);
29137    
29138                                    qPos.add(version);
29139    
29140                                    qPos.add(status);
29141    
29142                                    if (!pagination) {
29143                                            list = (List<JournalArticle>)QueryUtil.list(q,
29144                                                            getDialect(), start, end, false);
29145    
29146                                            Collections.sort(list);
29147    
29148                                            list = new UnmodifiableList<JournalArticle>(list);
29149                                    }
29150                                    else {
29151                                            list = (List<JournalArticle>)QueryUtil.list(q,
29152                                                            getDialect(), start, end);
29153                                    }
29154    
29155                                    cacheResult(list);
29156    
29157                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
29158                            }
29159                            catch (Exception e) {
29160                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
29161    
29162                                    throw processException(e);
29163                            }
29164                            finally {
29165                                    closeSession(session);
29166                            }
29167                    }
29168    
29169                    return list;
29170            }
29171    
29172            /**
29173             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
29174             *
29175             * @param companyId the company ID
29176             * @param version the version
29177             * @param status the status
29178             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
29179             * @return the first matching journal article
29180             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
29181             * @throws SystemException if a system exception occurred
29182             */
29183            @Override
29184            public JournalArticle findByC_V_ST_First(long companyId, double version,
29185                    int status, OrderByComparator orderByComparator)
29186                    throws NoSuchArticleException, SystemException {
29187                    JournalArticle journalArticle = fetchByC_V_ST_First(companyId, version,
29188                                    status, orderByComparator);
29189    
29190                    if (journalArticle != null) {
29191                            return journalArticle;
29192                    }
29193    
29194                    StringBundler msg = new StringBundler(8);
29195    
29196                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
29197    
29198                    msg.append("companyId=");
29199                    msg.append(companyId);
29200    
29201                    msg.append(", version=");
29202                    msg.append(version);
29203    
29204                    msg.append(", status=");
29205                    msg.append(status);
29206    
29207                    msg.append(StringPool.CLOSE_CURLY_BRACE);
29208    
29209                    throw new NoSuchArticleException(msg.toString());
29210            }
29211    
29212            /**
29213             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
29214             *
29215             * @param companyId the company ID
29216             * @param version the version
29217             * @param status the status
29218             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
29219             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
29220             * @throws SystemException if a system exception occurred
29221             */
29222            @Override
29223            public JournalArticle fetchByC_V_ST_First(long companyId, double version,
29224                    int status, OrderByComparator orderByComparator)
29225                    throws SystemException {
29226                    List<JournalArticle> list = findByC_V_ST(companyId, version, status, 0,
29227                                    1, orderByComparator);
29228    
29229                    if (!list.isEmpty()) {
29230                            return list.get(0);
29231                    }
29232    
29233                    return null;
29234            }
29235    
29236            /**
29237             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
29238             *
29239             * @param companyId the company ID
29240             * @param version the version
29241             * @param status the status
29242             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
29243             * @return the last matching journal article
29244             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
29245             * @throws SystemException if a system exception occurred
29246             */
29247            @Override
29248            public JournalArticle findByC_V_ST_Last(long companyId, double version,
29249                    int status, OrderByComparator orderByComparator)
29250                    throws NoSuchArticleException, SystemException {
29251                    JournalArticle journalArticle = fetchByC_V_ST_Last(companyId, version,
29252                                    status, orderByComparator);
29253    
29254                    if (journalArticle != null) {
29255                            return journalArticle;
29256                    }
29257    
29258                    StringBundler msg = new StringBundler(8);
29259    
29260                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
29261    
29262                    msg.append("companyId=");
29263                    msg.append(companyId);
29264    
29265                    msg.append(", version=");
29266                    msg.append(version);
29267    
29268                    msg.append(", status=");
29269                    msg.append(status);
29270    
29271                    msg.append(StringPool.CLOSE_CURLY_BRACE);
29272    
29273                    throw new NoSuchArticleException(msg.toString());
29274            }
29275    
29276            /**
29277             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
29278             *
29279             * @param companyId the company ID
29280             * @param version the version
29281             * @param status the status
29282             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
29283             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
29284             * @throws SystemException if a system exception occurred
29285             */
29286            @Override
29287            public JournalArticle fetchByC_V_ST_Last(long companyId, double version,
29288                    int status, OrderByComparator orderByComparator)
29289                    throws SystemException {
29290                    int count = countByC_V_ST(companyId, version, status);
29291    
29292                    if (count == 0) {
29293                            return null;
29294                    }
29295    
29296                    List<JournalArticle> list = findByC_V_ST(companyId, version, status,
29297                                    count - 1, count, orderByComparator);
29298    
29299                    if (!list.isEmpty()) {
29300                            return list.get(0);
29301                    }
29302    
29303                    return null;
29304            }
29305    
29306            /**
29307             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
29308             *
29309             * @param id the primary key of the current journal article
29310             * @param companyId the company ID
29311             * @param version the version
29312             * @param status the status
29313             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
29314             * @return the previous, current, and next journal article
29315             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
29316             * @throws SystemException if a system exception occurred
29317             */
29318            @Override
29319            public JournalArticle[] findByC_V_ST_PrevAndNext(long id, long companyId,
29320                    double version, int status, OrderByComparator orderByComparator)
29321                    throws NoSuchArticleException, SystemException {
29322                    JournalArticle journalArticle = findByPrimaryKey(id);
29323    
29324                    Session session = null;
29325    
29326                    try {
29327                            session = openSession();
29328    
29329                            JournalArticle[] array = new JournalArticleImpl[3];
29330    
29331                            array[0] = getByC_V_ST_PrevAndNext(session, journalArticle,
29332                                            companyId, version, status, orderByComparator, true);
29333    
29334                            array[1] = journalArticle;
29335    
29336                            array[2] = getByC_V_ST_PrevAndNext(session, journalArticle,
29337                                            companyId, version, status, orderByComparator, false);
29338    
29339                            return array;
29340                    }
29341                    catch (Exception e) {
29342                            throw processException(e);
29343                    }
29344                    finally {
29345                            closeSession(session);
29346                    }
29347            }
29348    
29349            protected JournalArticle getByC_V_ST_PrevAndNext(Session session,
29350                    JournalArticle journalArticle, long companyId, double version,
29351                    int status, OrderByComparator orderByComparator, boolean previous) {
29352                    StringBundler query = null;
29353    
29354                    if (orderByComparator != null) {
29355                            query = new StringBundler(6 +
29356                                            (orderByComparator.getOrderByFields().length * 6));
29357                    }
29358                    else {
29359                            query = new StringBundler(3);
29360                    }
29361    
29362                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
29363    
29364                    query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
29365    
29366                    query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
29367    
29368                    query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
29369    
29370                    if (orderByComparator != null) {
29371                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
29372    
29373                            if (orderByConditionFields.length > 0) {
29374                                    query.append(WHERE_AND);
29375                            }
29376    
29377                            for (int i = 0; i < orderByConditionFields.length; i++) {
29378                                    query.append(_ORDER_BY_ENTITY_ALIAS);
29379                                    query.append(orderByConditionFields[i]);
29380    
29381                                    if ((i + 1) < orderByConditionFields.length) {
29382                                            if (orderByComparator.isAscending() ^ previous) {
29383                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
29384                                            }
29385                                            else {
29386                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
29387                                            }
29388                                    }
29389                                    else {
29390                                            if (orderByComparator.isAscending() ^ previous) {
29391                                                    query.append(WHERE_GREATER_THAN);
29392                                            }
29393                                            else {
29394                                                    query.append(WHERE_LESSER_THAN);
29395                                            }
29396                                    }
29397                            }
29398    
29399                            query.append(ORDER_BY_CLAUSE);
29400    
29401                            String[] orderByFields = orderByComparator.getOrderByFields();
29402    
29403                            for (int i = 0; i < orderByFields.length; i++) {
29404                                    query.append(_ORDER_BY_ENTITY_ALIAS);
29405                                    query.append(orderByFields[i]);
29406    
29407                                    if ((i + 1) < orderByFields.length) {
29408                                            if (orderByComparator.isAscending() ^ previous) {
29409                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
29410                                            }
29411                                            else {
29412                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
29413                                            }
29414                                    }
29415                                    else {
29416                                            if (orderByComparator.isAscending() ^ previous) {
29417                                                    query.append(ORDER_BY_ASC);
29418                                            }
29419                                            else {
29420                                                    query.append(ORDER_BY_DESC);
29421                                            }
29422                                    }
29423                            }
29424                    }
29425                    else {
29426                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
29427                    }
29428    
29429                    String sql = query.toString();
29430    
29431                    Query q = session.createQuery(sql);
29432    
29433                    q.setFirstResult(0);
29434                    q.setMaxResults(2);
29435    
29436                    QueryPos qPos = QueryPos.getInstance(q);
29437    
29438                    qPos.add(companyId);
29439    
29440                    qPos.add(version);
29441    
29442                    qPos.add(status);
29443    
29444                    if (orderByComparator != null) {
29445                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
29446    
29447                            for (Object value : values) {
29448                                    qPos.add(value);
29449                            }
29450                    }
29451    
29452                    List<JournalArticle> list = q.list();
29453    
29454                    if (list.size() == 2) {
29455                            return list.get(1);
29456                    }
29457                    else {
29458                            return null;
29459                    }
29460            }
29461    
29462            /**
29463             * Removes all the journal articles where companyId = &#63; and version = &#63; and status = &#63; from the database.
29464             *
29465             * @param companyId the company ID
29466             * @param version the version
29467             * @param status the status
29468             * @throws SystemException if a system exception occurred
29469             */
29470            @Override
29471            public void removeByC_V_ST(long companyId, double version, int status)
29472                    throws SystemException {
29473                    for (JournalArticle journalArticle : findByC_V_ST(companyId, version,
29474                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
29475                            remove(journalArticle);
29476                    }
29477            }
29478    
29479            /**
29480             * Returns the number of journal articles where companyId = &#63; and version = &#63; and status = &#63;.
29481             *
29482             * @param companyId the company ID
29483             * @param version the version
29484             * @param status the status
29485             * @return the number of matching journal articles
29486             * @throws SystemException if a system exception occurred
29487             */
29488            @Override
29489            public int countByC_V_ST(long companyId, double version, int status)
29490                    throws SystemException {
29491                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_V_ST;
29492    
29493                    Object[] finderArgs = new Object[] { companyId, version, status };
29494    
29495                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
29496                                    this);
29497    
29498                    if (count == null) {
29499                            StringBundler query = new StringBundler(4);
29500    
29501                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
29502    
29503                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
29504    
29505                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
29506    
29507                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
29508    
29509                            String sql = query.toString();
29510    
29511                            Session session = null;
29512    
29513                            try {
29514                                    session = openSession();
29515    
29516                                    Query q = session.createQuery(sql);
29517    
29518                                    QueryPos qPos = QueryPos.getInstance(q);
29519    
29520                                    qPos.add(companyId);
29521    
29522                                    qPos.add(version);
29523    
29524                                    qPos.add(status);
29525    
29526                                    count = (Long)q.uniqueResult();
29527    
29528                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
29529                            }
29530                            catch (Exception e) {
29531                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
29532    
29533                                    throw processException(e);
29534                            }
29535                            finally {
29536                                    closeSession(session);
29537                            }
29538                    }
29539    
29540                    return count.intValue();
29541            }
29542    
29543            private static final String _FINDER_COLUMN_C_V_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
29544            private static final String _FINDER_COLUMN_C_V_ST_VERSION_2 = "journalArticle.version = ? AND ";
29545            private static final String _FINDER_COLUMN_C_V_ST_STATUS_2 = "journalArticle.status = ?";
29546    
29547            public JournalArticlePersistenceImpl() {
29548                    setModelClass(JournalArticle.class);
29549            }
29550    
29551            /**
29552             * Caches the journal article in the entity cache if it is enabled.
29553             *
29554             * @param journalArticle the journal article
29555             */
29556            @Override
29557            public void cacheResult(JournalArticle journalArticle) {
29558                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
29559                            JournalArticleImpl.class, journalArticle.getPrimaryKey(),
29560                            journalArticle);
29561    
29562                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
29563                            new Object[] { journalArticle.getUuid(), journalArticle.getGroupId() },
29564                            journalArticle);
29565    
29566                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
29567                            new Object[] {
29568                                    journalArticle.getGroupId(), journalArticle.getClassNameId(),
29569                                    journalArticle.getStructureId()
29570                            }, journalArticle);
29571    
29572                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
29573                            new Object[] {
29574                                    journalArticle.getGroupId(), journalArticle.getArticleId(),
29575                                    journalArticle.getVersion()
29576                            }, journalArticle);
29577    
29578                    journalArticle.resetOriginalValues();
29579            }
29580    
29581            /**
29582             * Caches the journal articles in the entity cache if it is enabled.
29583             *
29584             * @param journalArticles the journal articles
29585             */
29586            @Override
29587            public void cacheResult(List<JournalArticle> journalArticles) {
29588                    for (JournalArticle journalArticle : journalArticles) {
29589                            if (EntityCacheUtil.getResult(
29590                                                    JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
29591                                                    JournalArticleImpl.class, journalArticle.getPrimaryKey()) == null) {
29592                                    cacheResult(journalArticle);
29593                            }
29594                            else {
29595                                    journalArticle.resetOriginalValues();
29596                            }
29597                    }
29598            }
29599    
29600            /**
29601             * Clears the cache for all journal articles.
29602             *
29603             * <p>
29604             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
29605             * </p>
29606             */
29607            @Override
29608            public void clearCache() {
29609                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
29610                            CacheRegistryUtil.clear(JournalArticleImpl.class.getName());
29611                    }
29612    
29613                    EntityCacheUtil.clearCache(JournalArticleImpl.class.getName());
29614    
29615                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
29616                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
29617                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
29618            }
29619    
29620            /**
29621             * Clears the cache for the journal article.
29622             *
29623             * <p>
29624             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
29625             * </p>
29626             */
29627            @Override
29628            public void clearCache(JournalArticle journalArticle) {
29629                    EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
29630                            JournalArticleImpl.class, journalArticle.getPrimaryKey());
29631    
29632                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
29633                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
29634    
29635                    clearUniqueFindersCache(journalArticle);
29636            }
29637    
29638            @Override
29639            public void clearCache(List<JournalArticle> journalArticles) {
29640                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
29641                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
29642    
29643                    for (JournalArticle journalArticle : journalArticles) {
29644                            EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
29645                                    JournalArticleImpl.class, journalArticle.getPrimaryKey());
29646    
29647                            clearUniqueFindersCache(journalArticle);
29648                    }
29649            }
29650    
29651            protected void cacheUniqueFindersCache(JournalArticle journalArticle) {
29652                    if (journalArticle.isNew()) {
29653                            Object[] args = new Object[] {
29654                                            journalArticle.getUuid(), journalArticle.getGroupId()
29655                                    };
29656    
29657                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
29658                                    Long.valueOf(1));
29659                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
29660                                    journalArticle);
29661    
29662                            args = new Object[] {
29663                                            journalArticle.getGroupId(), journalArticle.getClassNameId(),
29664                                            journalArticle.getStructureId()
29665                                    };
29666    
29667                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S, args,
29668                                    Long.valueOf(1));
29669                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S, args,
29670                                    journalArticle);
29671    
29672                            args = new Object[] {
29673                                            journalArticle.getGroupId(), journalArticle.getArticleId(),
29674                                            journalArticle.getVersion()
29675                                    };
29676    
29677                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V, args,
29678                                    Long.valueOf(1));
29679                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V, args,
29680                                    journalArticle);
29681                    }
29682                    else {
29683                            JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
29684    
29685                            if ((journalArticleModelImpl.getColumnBitmask() &
29686                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
29687                                    Object[] args = new Object[] {
29688                                                    journalArticle.getUuid(), journalArticle.getGroupId()
29689                                            };
29690    
29691                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
29692                                            Long.valueOf(1));
29693                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
29694                                            journalArticle);
29695                            }
29696    
29697                            if ((journalArticleModelImpl.getColumnBitmask() &
29698                                            FINDER_PATH_FETCH_BY_G_C_S.getColumnBitmask()) != 0) {
29699                                    Object[] args = new Object[] {
29700                                                    journalArticle.getGroupId(),
29701                                                    journalArticle.getClassNameId(),
29702                                                    journalArticle.getStructureId()
29703                                            };
29704    
29705                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S, args,
29706                                            Long.valueOf(1));
29707                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S, args,
29708                                            journalArticle);
29709                            }
29710    
29711                            if ((journalArticleModelImpl.getColumnBitmask() &
29712                                            FINDER_PATH_FETCH_BY_G_A_V.getColumnBitmask()) != 0) {
29713                                    Object[] args = new Object[] {
29714                                                    journalArticle.getGroupId(),
29715                                                    journalArticle.getArticleId(),
29716                                                    journalArticle.getVersion()
29717                                            };
29718    
29719                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V, args,
29720                                            Long.valueOf(1));
29721                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V, args,
29722                                            journalArticle);
29723                            }
29724                    }
29725            }
29726    
29727            protected void clearUniqueFindersCache(JournalArticle journalArticle) {
29728                    JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
29729    
29730                    Object[] args = new Object[] {
29731                                    journalArticle.getUuid(), journalArticle.getGroupId()
29732                            };
29733    
29734                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
29735                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
29736    
29737                    if ((journalArticleModelImpl.getColumnBitmask() &
29738                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
29739                            args = new Object[] {
29740                                            journalArticleModelImpl.getOriginalUuid(),
29741                                            journalArticleModelImpl.getOriginalGroupId()
29742                                    };
29743    
29744                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
29745                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
29746                    }
29747    
29748                    args = new Object[] {
29749                                    journalArticle.getGroupId(), journalArticle.getClassNameId(),
29750                                    journalArticle.getStructureId()
29751                            };
29752    
29753                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
29754                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S, args);
29755    
29756                    if ((journalArticleModelImpl.getColumnBitmask() &
29757                                    FINDER_PATH_FETCH_BY_G_C_S.getColumnBitmask()) != 0) {
29758                            args = new Object[] {
29759                                            journalArticleModelImpl.getOriginalGroupId(),
29760                                            journalArticleModelImpl.getOriginalClassNameId(),
29761                                            journalArticleModelImpl.getOriginalStructureId()
29762                                    };
29763    
29764                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
29765                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S, args);
29766                    }
29767    
29768                    args = new Object[] {
29769                                    journalArticle.getGroupId(), journalArticle.getArticleId(),
29770                                    journalArticle.getVersion()
29771                            };
29772    
29773                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_V, args);
29774                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V, args);
29775    
29776                    if ((journalArticleModelImpl.getColumnBitmask() &
29777                                    FINDER_PATH_FETCH_BY_G_A_V.getColumnBitmask()) != 0) {
29778                            args = new Object[] {
29779                                            journalArticleModelImpl.getOriginalGroupId(),
29780                                            journalArticleModelImpl.getOriginalArticleId(),
29781                                            journalArticleModelImpl.getOriginalVersion()
29782                                    };
29783    
29784                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_V, args);
29785                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V, args);
29786                    }
29787            }
29788    
29789            /**
29790             * Creates a new journal article with the primary key. Does not add the journal article to the database.
29791             *
29792             * @param id the primary key for the new journal article
29793             * @return the new journal article
29794             */
29795            @Override
29796            public JournalArticle create(long id) {
29797                    JournalArticle journalArticle = new JournalArticleImpl();
29798    
29799                    journalArticle.setNew(true);
29800                    journalArticle.setPrimaryKey(id);
29801    
29802                    String uuid = PortalUUIDUtil.generate();
29803    
29804                    journalArticle.setUuid(uuid);
29805    
29806                    return journalArticle;
29807            }
29808    
29809            /**
29810             * Removes the journal article with the primary key from the database. Also notifies the appropriate model listeners.
29811             *
29812             * @param id the primary key of the journal article
29813             * @return the journal article that was removed
29814             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
29815             * @throws SystemException if a system exception occurred
29816             */
29817            @Override
29818            public JournalArticle remove(long id)
29819                    throws NoSuchArticleException, SystemException {
29820                    return remove((Serializable)id);
29821            }
29822    
29823            /**
29824             * Removes the journal article with the primary key from the database. Also notifies the appropriate model listeners.
29825             *
29826             * @param primaryKey the primary key of the journal article
29827             * @return the journal article that was removed
29828             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
29829             * @throws SystemException if a system exception occurred
29830             */
29831            @Override
29832            public JournalArticle remove(Serializable primaryKey)
29833                    throws NoSuchArticleException, SystemException {
29834                    Session session = null;
29835    
29836                    try {
29837                            session = openSession();
29838    
29839                            JournalArticle journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
29840                                            primaryKey);
29841    
29842                            if (journalArticle == null) {
29843                                    if (_log.isWarnEnabled()) {
29844                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
29845                                    }
29846    
29847                                    throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
29848                                            primaryKey);
29849                            }
29850    
29851                            return remove(journalArticle);
29852                    }
29853                    catch (NoSuchArticleException nsee) {
29854                            throw nsee;
29855                    }
29856                    catch (Exception e) {
29857                            throw processException(e);
29858                    }
29859                    finally {
29860                            closeSession(session);
29861                    }
29862            }
29863    
29864            @Override
29865            protected JournalArticle removeImpl(JournalArticle journalArticle)
29866                    throws SystemException {
29867                    journalArticle = toUnwrappedModel(journalArticle);
29868    
29869                    Session session = null;
29870    
29871                    try {
29872                            session = openSession();
29873    
29874                            if (!session.contains(journalArticle)) {
29875                                    journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
29876                                                    journalArticle.getPrimaryKeyObj());
29877                            }
29878    
29879                            if (journalArticle != null) {
29880                                    session.delete(journalArticle);
29881                            }
29882                    }
29883                    catch (Exception e) {
29884                            throw processException(e);
29885                    }
29886                    finally {
29887                            closeSession(session);
29888                    }
29889    
29890                    if (journalArticle != null) {
29891                            clearCache(journalArticle);
29892                    }
29893    
29894                    return journalArticle;
29895            }
29896    
29897            @Override
29898            public JournalArticle updateImpl(
29899                    com.liferay.portlet.journal.model.JournalArticle journalArticle)
29900                    throws SystemException {
29901                    journalArticle = toUnwrappedModel(journalArticle);
29902    
29903                    boolean isNew = journalArticle.isNew();
29904    
29905                    JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
29906    
29907                    if (Validator.isNull(journalArticle.getUuid())) {
29908                            String uuid = PortalUUIDUtil.generate();
29909    
29910                            journalArticle.setUuid(uuid);
29911                    }
29912    
29913                    Session session = null;
29914    
29915                    try {
29916                            session = openSession();
29917    
29918                            if (journalArticle.isNew()) {
29919                                    session.save(journalArticle);
29920    
29921                                    journalArticle.setNew(false);
29922                            }
29923                            else {
29924                                    session.merge(journalArticle);
29925                            }
29926                    }
29927                    catch (Exception e) {
29928                            throw processException(e);
29929                    }
29930                    finally {
29931                            closeSession(session);
29932                    }
29933    
29934                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
29935    
29936                    if (isNew || !JournalArticleModelImpl.COLUMN_BITMASK_ENABLED) {
29937                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
29938                    }
29939    
29940                    else {
29941                            if ((journalArticleModelImpl.getColumnBitmask() &
29942                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
29943                                    Object[] args = new Object[] {
29944                                                    journalArticleModelImpl.getOriginalUuid()
29945                                            };
29946    
29947                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
29948                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
29949                                            args);
29950    
29951                                    args = new Object[] { journalArticleModelImpl.getUuid() };
29952    
29953                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
29954                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
29955                                            args);
29956                            }
29957    
29958                            if ((journalArticleModelImpl.getColumnBitmask() &
29959                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
29960                                    Object[] args = new Object[] {
29961                                                    journalArticleModelImpl.getOriginalUuid(),
29962                                                    journalArticleModelImpl.getOriginalCompanyId()
29963                                            };
29964    
29965                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
29966                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
29967                                            args);
29968    
29969                                    args = new Object[] {
29970                                                    journalArticleModelImpl.getUuid(),
29971                                                    journalArticleModelImpl.getCompanyId()
29972                                            };
29973    
29974                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
29975                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
29976                                            args);
29977                            }
29978    
29979                            if ((journalArticleModelImpl.getColumnBitmask() &
29980                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY.getColumnBitmask()) != 0) {
29981                                    Object[] args = new Object[] {
29982                                                    journalArticleModelImpl.getOriginalResourcePrimKey()
29983                                            };
29984    
29985                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
29986                                            args);
29987                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
29988                                            args);
29989    
29990                                    args = new Object[] { journalArticleModelImpl.getResourcePrimKey() };
29991    
29992                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
29993                                            args);
29994                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
29995                                            args);
29996                            }
29997    
29998                            if ((journalArticleModelImpl.getColumnBitmask() &
29999                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
30000                                    Object[] args = new Object[] {
30001                                                    journalArticleModelImpl.getOriginalGroupId()
30002                                            };
30003    
30004                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
30005                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
30006                                            args);
30007    
30008                                    args = new Object[] { journalArticleModelImpl.getGroupId() };
30009    
30010                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
30011                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
30012                                            args);
30013                            }
30014    
30015                            if ((journalArticleModelImpl.getColumnBitmask() &
30016                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
30017                                    Object[] args = new Object[] {
30018                                                    journalArticleModelImpl.getOriginalCompanyId()
30019                                            };
30020    
30021                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
30022                                            args);
30023                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
30024                                            args);
30025    
30026                                    args = new Object[] { journalArticleModelImpl.getCompanyId() };
30027    
30028                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
30029                                            args);
30030                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
30031                                            args);
30032                            }
30033    
30034                            if ((journalArticleModelImpl.getColumnBitmask() &
30035                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID.getColumnBitmask()) != 0) {
30036                                    Object[] args = new Object[] {
30037                                                    journalArticleModelImpl.getOriginalStructureId()
30038                                            };
30039    
30040                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
30041                                            args);
30042                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
30043                                            args);
30044    
30045                                    args = new Object[] { journalArticleModelImpl.getStructureId() };
30046    
30047                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
30048                                            args);
30049                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
30050                                            args);
30051                            }
30052    
30053                            if ((journalArticleModelImpl.getColumnBitmask() &
30054                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID.getColumnBitmask()) != 0) {
30055                                    Object[] args = new Object[] {
30056                                                    journalArticleModelImpl.getOriginalTemplateId()
30057                                            };
30058    
30059                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
30060                                            args);
30061                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID,
30062                                            args);
30063    
30064                                    args = new Object[] { journalArticleModelImpl.getTemplateId() };
30065    
30066                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
30067                                            args);
30068                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID,
30069                                            args);
30070                            }
30071    
30072                            if ((journalArticleModelImpl.getColumnBitmask() &
30073                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID.getColumnBitmask()) != 0) {
30074                                    Object[] args = new Object[] {
30075                                                    journalArticleModelImpl.getOriginalLayoutUuid()
30076                                            };
30077    
30078                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTUUID,
30079                                            args);
30080                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID,
30081                                            args);
30082    
30083                                    args = new Object[] { journalArticleModelImpl.getLayoutUuid() };
30084    
30085                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTUUID,
30086                                            args);
30087                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID,
30088                                            args);
30089                            }
30090    
30091                            if ((journalArticleModelImpl.getColumnBitmask() &
30092                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID.getColumnBitmask()) != 0) {
30093                                    Object[] args = new Object[] {
30094                                                    journalArticleModelImpl.getOriginalSmallImageId()
30095                                            };
30096    
30097                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
30098                                            args);
30099                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID,
30100                                            args);
30101    
30102                                    args = new Object[] { journalArticleModelImpl.getSmallImageId() };
30103    
30104                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
30105                                            args);
30106                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID,
30107                                            args);
30108                            }
30109    
30110                            if ((journalArticleModelImpl.getColumnBitmask() &
30111                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I.getColumnBitmask()) != 0) {
30112                                    Object[] args = new Object[] {
30113                                                    journalArticleModelImpl.getOriginalResourcePrimKey(),
30114                                                    journalArticleModelImpl.getOriginalIndexable()
30115                                            };
30116    
30117                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_I, args);
30118                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I,
30119                                            args);
30120    
30121                                    args = new Object[] {
30122                                                    journalArticleModelImpl.getResourcePrimKey(),
30123                                                    journalArticleModelImpl.getIndexable()
30124                                            };
30125    
30126                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_I, args);
30127                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I,
30128                                            args);
30129                            }
30130    
30131                            if ((journalArticleModelImpl.getColumnBitmask() &
30132                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST.getColumnBitmask()) != 0) {
30133                                    Object[] args = new Object[] {
30134                                                    journalArticleModelImpl.getOriginalResourcePrimKey(),
30135                                                    journalArticleModelImpl.getOriginalStatus()
30136                                            };
30137    
30138                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_ST, args);
30139                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST,
30140                                            args);
30141    
30142                                    args = new Object[] {
30143                                                    journalArticleModelImpl.getResourcePrimKey(),
30144                                                    journalArticleModelImpl.getStatus()
30145                                            };
30146    
30147                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_ST, args);
30148                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST,
30149                                            args);
30150                            }
30151    
30152                            if ((journalArticleModelImpl.getColumnBitmask() &
30153                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U.getColumnBitmask()) != 0) {
30154                                    Object[] args = new Object[] {
30155                                                    journalArticleModelImpl.getOriginalGroupId(),
30156                                                    journalArticleModelImpl.getOriginalUserId()
30157                                            };
30158    
30159                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
30160                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
30161                                            args);
30162    
30163                                    args = new Object[] {
30164                                                    journalArticleModelImpl.getGroupId(),
30165                                                    journalArticleModelImpl.getUserId()
30166                                            };
30167    
30168                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
30169                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
30170                                            args);
30171                            }
30172    
30173                            if ((journalArticleModelImpl.getColumnBitmask() &
30174                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F.getColumnBitmask()) != 0) {
30175                                    Object[] args = new Object[] {
30176                                                    journalArticleModelImpl.getOriginalGroupId(),
30177                                                    journalArticleModelImpl.getOriginalFolderId()
30178                                            };
30179    
30180                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
30181                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
30182                                            args);
30183    
30184                                    args = new Object[] {
30185                                                    journalArticleModelImpl.getGroupId(),
30186                                                    journalArticleModelImpl.getFolderId()
30187                                            };
30188    
30189                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
30190                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
30191                                            args);
30192                            }
30193    
30194                            if ((journalArticleModelImpl.getColumnBitmask() &
30195                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A.getColumnBitmask()) != 0) {
30196                                    Object[] args = new Object[] {
30197                                                    journalArticleModelImpl.getOriginalGroupId(),
30198                                                    journalArticleModelImpl.getOriginalArticleId()
30199                                            };
30200    
30201                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
30202                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
30203                                            args);
30204    
30205                                    args = new Object[] {
30206                                                    journalArticleModelImpl.getGroupId(),
30207                                                    journalArticleModelImpl.getArticleId()
30208                                            };
30209    
30210                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
30211                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
30212                                            args);
30213                            }
30214    
30215                            if ((journalArticleModelImpl.getColumnBitmask() &
30216                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT.getColumnBitmask()) != 0) {
30217                                    Object[] args = new Object[] {
30218                                                    journalArticleModelImpl.getOriginalGroupId(),
30219                                                    journalArticleModelImpl.getOriginalUrlTitle()
30220                                            };
30221    
30222                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
30223                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT,
30224                                            args);
30225    
30226                                    args = new Object[] {
30227                                                    journalArticleModelImpl.getGroupId(),
30228                                                    journalArticleModelImpl.getUrlTitle()
30229                                            };
30230    
30231                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
30232                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT,
30233                                            args);
30234                            }
30235    
30236                            if ((journalArticleModelImpl.getColumnBitmask() &
30237                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
30238                                    Object[] args = new Object[] {
30239                                                    journalArticleModelImpl.getOriginalGroupId(),
30240                                                    journalArticleModelImpl.getOriginalStructureId()
30241                                            };
30242    
30243                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
30244                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
30245                                            args);
30246    
30247                                    args = new Object[] {
30248                                                    journalArticleModelImpl.getGroupId(),
30249                                                    journalArticleModelImpl.getStructureId()
30250                                            };
30251    
30252                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
30253                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
30254                                            args);
30255                            }
30256    
30257                            if ((journalArticleModelImpl.getColumnBitmask() &
30258                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T.getColumnBitmask()) != 0) {
30259                                    Object[] args = new Object[] {
30260                                                    journalArticleModelImpl.getOriginalGroupId(),
30261                                                    journalArticleModelImpl.getOriginalTemplateId()
30262                                            };
30263    
30264                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_T, args);
30265                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T,
30266                                            args);
30267    
30268                                    args = new Object[] {
30269                                                    journalArticleModelImpl.getGroupId(),
30270                                                    journalArticleModelImpl.getTemplateId()
30271                                            };
30272    
30273                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_T, args);
30274                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T,
30275                                            args);
30276                            }
30277    
30278                            if ((journalArticleModelImpl.getColumnBitmask() &
30279                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L.getColumnBitmask()) != 0) {
30280                                    Object[] args = new Object[] {
30281                                                    journalArticleModelImpl.getOriginalGroupId(),
30282                                                    journalArticleModelImpl.getOriginalLayoutUuid()
30283                                            };
30284    
30285                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_L, args);
30286                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L,
30287                                            args);
30288    
30289                                    args = new Object[] {
30290                                                    journalArticleModelImpl.getGroupId(),
30291                                                    journalArticleModelImpl.getLayoutUuid()
30292                                            };
30293    
30294                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_L, args);
30295                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L,
30296                                            args);
30297                            }
30298    
30299                            if ((journalArticleModelImpl.getColumnBitmask() &
30300                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST.getColumnBitmask()) != 0) {
30301                                    Object[] args = new Object[] {
30302                                                    journalArticleModelImpl.getOriginalGroupId(),
30303                                                    journalArticleModelImpl.getOriginalStatus()
30304                                            };
30305    
30306                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_ST, args);
30307                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST,
30308                                            args);
30309    
30310                                    args = new Object[] {
30311                                                    journalArticleModelImpl.getGroupId(),
30312                                                    journalArticleModelImpl.getStatus()
30313                                            };
30314    
30315                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_ST, args);
30316                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST,
30317                                            args);
30318                            }
30319    
30320                            if ((journalArticleModelImpl.getColumnBitmask() &
30321                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V.getColumnBitmask()) != 0) {
30322                                    Object[] args = new Object[] {
30323                                                    journalArticleModelImpl.getOriginalCompanyId(),
30324                                                    journalArticleModelImpl.getOriginalVersion()
30325                                            };
30326    
30327                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V, args);
30328                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V,
30329                                            args);
30330    
30331                                    args = new Object[] {
30332                                                    journalArticleModelImpl.getCompanyId(),
30333                                                    journalArticleModelImpl.getVersion()
30334                                            };
30335    
30336                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V, args);
30337                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V,
30338                                            args);
30339                            }
30340    
30341                            if ((journalArticleModelImpl.getColumnBitmask() &
30342                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST.getColumnBitmask()) != 0) {
30343                                    Object[] args = new Object[] {
30344                                                    journalArticleModelImpl.getOriginalCompanyId(),
30345                                                    journalArticleModelImpl.getOriginalStatus()
30346                                            };
30347    
30348                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_ST, args);
30349                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST,
30350                                            args);
30351    
30352                                    args = new Object[] {
30353                                                    journalArticleModelImpl.getCompanyId(),
30354                                                    journalArticleModelImpl.getStatus()
30355                                            };
30356    
30357                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_ST, args);
30358                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST,
30359                                            args);
30360                            }
30361    
30362                            if ((journalArticleModelImpl.getColumnBitmask() &
30363                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T.getColumnBitmask()) != 0) {
30364                                    Object[] args = new Object[] {
30365                                                    journalArticleModelImpl.getOriginalClassNameId(),
30366                                                    journalArticleModelImpl.getOriginalTemplateId()
30367                                            };
30368    
30369                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_T, args);
30370                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T,
30371                                            args);
30372    
30373                                    args = new Object[] {
30374                                                    journalArticleModelImpl.getClassNameId(),
30375                                                    journalArticleModelImpl.getTemplateId()
30376                                            };
30377    
30378                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_T, args);
30379                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T,
30380                                            args);
30381                            }
30382    
30383                            if ((journalArticleModelImpl.getColumnBitmask() &
30384                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S.getColumnBitmask()) != 0) {
30385                                    Object[] args = new Object[] {
30386                                                    journalArticleModelImpl.getOriginalResourcePrimKey(),
30387                                                    journalArticleModelImpl.getOriginalIndexable(),
30388                                                    journalArticleModelImpl.getOriginalStatus()
30389                                            };
30390    
30391                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_I_S, args);
30392                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S,
30393                                            args);
30394    
30395                                    args = new Object[] {
30396                                                    journalArticleModelImpl.getResourcePrimKey(),
30397                                                    journalArticleModelImpl.getIndexable(),
30398                                                    journalArticleModelImpl.getStatus()
30399                                            };
30400    
30401                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_I_S, args);
30402                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S,
30403                                            args);
30404                            }
30405    
30406                            if ((journalArticleModelImpl.getColumnBitmask() &
30407                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C.getColumnBitmask()) != 0) {
30408                                    Object[] args = new Object[] {
30409                                                    journalArticleModelImpl.getOriginalGroupId(),
30410                                                    journalArticleModelImpl.getOriginalUserId(),
30411                                                    journalArticleModelImpl.getOriginalClassNameId()
30412                                            };
30413    
30414                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_C, args);
30415                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C,
30416                                            args);
30417    
30418                                    args = new Object[] {
30419                                                    journalArticleModelImpl.getGroupId(),
30420                                                    journalArticleModelImpl.getUserId(),
30421                                                    journalArticleModelImpl.getClassNameId()
30422                                            };
30423    
30424                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_C, args);
30425                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C,
30426                                            args);
30427                            }
30428    
30429                            if ((journalArticleModelImpl.getColumnBitmask() &
30430                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST.getColumnBitmask()) != 0) {
30431                                    Object[] args = new Object[] {
30432                                                    journalArticleModelImpl.getOriginalGroupId(),
30433                                                    journalArticleModelImpl.getOriginalFolderId(),
30434                                                    journalArticleModelImpl.getOriginalStatus()
30435                                            };
30436    
30437                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_ST, args);
30438                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST,
30439                                            args);
30440    
30441                                    args = new Object[] {
30442                                                    journalArticleModelImpl.getGroupId(),
30443                                                    journalArticleModelImpl.getFolderId(),
30444                                                    journalArticleModelImpl.getStatus()
30445                                            };
30446    
30447                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_ST, args);
30448                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST,
30449                                            args);
30450                            }
30451    
30452                            if ((journalArticleModelImpl.getColumnBitmask() &
30453                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C.getColumnBitmask()) != 0) {
30454                                    Object[] args = new Object[] {
30455                                                    journalArticleModelImpl.getOriginalGroupId(),
30456                                                    journalArticleModelImpl.getOriginalClassNameId(),
30457                                                    journalArticleModelImpl.getOriginalClassPK()
30458                                            };
30459    
30460                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
30461                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
30462                                            args);
30463    
30464                                    args = new Object[] {
30465                                                    journalArticleModelImpl.getGroupId(),
30466                                                    journalArticleModelImpl.getClassNameId(),
30467                                                    journalArticleModelImpl.getClassPK()
30468                                            };
30469    
30470                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
30471                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
30472                                            args);
30473                            }
30474    
30475                            if ((journalArticleModelImpl.getColumnBitmask() &
30476                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T.getColumnBitmask()) != 0) {
30477                                    Object[] args = new Object[] {
30478                                                    journalArticleModelImpl.getOriginalGroupId(),
30479                                                    journalArticleModelImpl.getOriginalClassNameId(),
30480                                                    journalArticleModelImpl.getOriginalTemplateId()
30481                                            };
30482    
30483                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args);
30484                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T,
30485                                            args);
30486    
30487                                    args = new Object[] {
30488                                                    journalArticleModelImpl.getGroupId(),
30489                                                    journalArticleModelImpl.getClassNameId(),
30490                                                    journalArticleModelImpl.getTemplateId()
30491                                            };
30492    
30493                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args);
30494                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T,
30495                                            args);
30496                            }
30497    
30498                            if ((journalArticleModelImpl.getColumnBitmask() &
30499                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L.getColumnBitmask()) != 0) {
30500                                    Object[] args = new Object[] {
30501                                                    journalArticleModelImpl.getOriginalGroupId(),
30502                                                    journalArticleModelImpl.getOriginalClassNameId(),
30503                                                    journalArticleModelImpl.getOriginalLayoutUuid()
30504                                            };
30505    
30506                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
30507                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
30508                                            args);
30509    
30510                                    args = new Object[] {
30511                                                    journalArticleModelImpl.getGroupId(),
30512                                                    journalArticleModelImpl.getClassNameId(),
30513                                                    journalArticleModelImpl.getLayoutUuid()
30514                                            };
30515    
30516                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
30517                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
30518                                            args);
30519                            }
30520    
30521                            if ((journalArticleModelImpl.getColumnBitmask() &
30522                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST.getColumnBitmask()) != 0) {
30523                                    Object[] args = new Object[] {
30524                                                    journalArticleModelImpl.getOriginalGroupId(),
30525                                                    journalArticleModelImpl.getOriginalArticleId(),
30526                                                    journalArticleModelImpl.getOriginalStatus()
30527                                            };
30528    
30529                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_ST, args);
30530                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST,
30531                                            args);
30532    
30533                                    args = new Object[] {
30534                                                    journalArticleModelImpl.getGroupId(),
30535                                                    journalArticleModelImpl.getArticleId(),
30536                                                    journalArticleModelImpl.getStatus()
30537                                            };
30538    
30539                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_ST, args);
30540                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST,
30541                                            args);
30542                            }
30543    
30544                            if ((journalArticleModelImpl.getColumnBitmask() &
30545                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST.getColumnBitmask()) != 0) {
30546                                    Object[] args = new Object[] {
30547                                                    journalArticleModelImpl.getOriginalGroupId(),
30548                                                    journalArticleModelImpl.getOriginalUrlTitle(),
30549                                                    journalArticleModelImpl.getOriginalStatus()
30550                                            };
30551    
30552                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT_ST, args);
30553                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST,
30554                                            args);
30555    
30556                                    args = new Object[] {
30557                                                    journalArticleModelImpl.getGroupId(),
30558                                                    journalArticleModelImpl.getUrlTitle(),
30559                                                    journalArticleModelImpl.getStatus()
30560                                            };
30561    
30562                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT_ST, args);
30563                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST,
30564                                            args);
30565                            }
30566    
30567                            if ((journalArticleModelImpl.getColumnBitmask() &
30568                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST.getColumnBitmask()) != 0) {
30569                                    Object[] args = new Object[] {
30570                                                    journalArticleModelImpl.getOriginalCompanyId(),
30571                                                    journalArticleModelImpl.getOriginalVersion(),
30572                                                    journalArticleModelImpl.getOriginalStatus()
30573                                            };
30574    
30575                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V_ST, args);
30576                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST,
30577                                            args);
30578    
30579                                    args = new Object[] {
30580                                                    journalArticleModelImpl.getCompanyId(),
30581                                                    journalArticleModelImpl.getVersion(),
30582                                                    journalArticleModelImpl.getStatus()
30583                                            };
30584    
30585                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V_ST, args);
30586                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST,
30587                                            args);
30588                            }
30589                    }
30590    
30591                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
30592                            JournalArticleImpl.class, journalArticle.getPrimaryKey(),
30593                            journalArticle);
30594    
30595                    clearUniqueFindersCache(journalArticle);
30596                    cacheUniqueFindersCache(journalArticle);
30597    
30598                    return journalArticle;
30599            }
30600    
30601            protected JournalArticle toUnwrappedModel(JournalArticle journalArticle) {
30602                    if (journalArticle instanceof JournalArticleImpl) {
30603                            return journalArticle;
30604                    }
30605    
30606                    JournalArticleImpl journalArticleImpl = new JournalArticleImpl();
30607    
30608                    journalArticleImpl.setNew(journalArticle.isNew());
30609                    journalArticleImpl.setPrimaryKey(journalArticle.getPrimaryKey());
30610    
30611                    journalArticleImpl.setUuid(journalArticle.getUuid());
30612                    journalArticleImpl.setId(journalArticle.getId());
30613                    journalArticleImpl.setResourcePrimKey(journalArticle.getResourcePrimKey());
30614                    journalArticleImpl.setGroupId(journalArticle.getGroupId());
30615                    journalArticleImpl.setCompanyId(journalArticle.getCompanyId());
30616                    journalArticleImpl.setUserId(journalArticle.getUserId());
30617                    journalArticleImpl.setUserName(journalArticle.getUserName());
30618                    journalArticleImpl.setCreateDate(journalArticle.getCreateDate());
30619                    journalArticleImpl.setModifiedDate(journalArticle.getModifiedDate());
30620                    journalArticleImpl.setFolderId(journalArticle.getFolderId());
30621                    journalArticleImpl.setClassNameId(journalArticle.getClassNameId());
30622                    journalArticleImpl.setClassPK(journalArticle.getClassPK());
30623                    journalArticleImpl.setTreePath(journalArticle.getTreePath());
30624                    journalArticleImpl.setArticleId(journalArticle.getArticleId());
30625                    journalArticleImpl.setVersion(journalArticle.getVersion());
30626                    journalArticleImpl.setTitle(journalArticle.getTitle());
30627                    journalArticleImpl.setUrlTitle(journalArticle.getUrlTitle());
30628                    journalArticleImpl.setDescription(journalArticle.getDescription());
30629                    journalArticleImpl.setContent(journalArticle.getContent());
30630                    journalArticleImpl.setType(journalArticle.getType());
30631                    journalArticleImpl.setStructureId(journalArticle.getStructureId());
30632                    journalArticleImpl.setTemplateId(journalArticle.getTemplateId());
30633                    journalArticleImpl.setLayoutUuid(journalArticle.getLayoutUuid());
30634                    journalArticleImpl.setDisplayDate(journalArticle.getDisplayDate());
30635                    journalArticleImpl.setExpirationDate(journalArticle.getExpirationDate());
30636                    journalArticleImpl.setReviewDate(journalArticle.getReviewDate());
30637                    journalArticleImpl.setIndexable(journalArticle.isIndexable());
30638                    journalArticleImpl.setSmallImage(journalArticle.isSmallImage());
30639                    journalArticleImpl.setSmallImageId(journalArticle.getSmallImageId());
30640                    journalArticleImpl.setSmallImageURL(journalArticle.getSmallImageURL());
30641                    journalArticleImpl.setStatus(journalArticle.getStatus());
30642                    journalArticleImpl.setStatusByUserId(journalArticle.getStatusByUserId());
30643                    journalArticleImpl.setStatusByUserName(journalArticle.getStatusByUserName());
30644                    journalArticleImpl.setStatusDate(journalArticle.getStatusDate());
30645    
30646                    return journalArticleImpl;
30647            }
30648    
30649            /**
30650             * Returns the journal article with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
30651             *
30652             * @param primaryKey the primary key of the journal article
30653             * @return the journal article
30654             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
30655             * @throws SystemException if a system exception occurred
30656             */
30657            @Override
30658            public JournalArticle findByPrimaryKey(Serializable primaryKey)
30659                    throws NoSuchArticleException, SystemException {
30660                    JournalArticle journalArticle = fetchByPrimaryKey(primaryKey);
30661    
30662                    if (journalArticle == null) {
30663                            if (_log.isWarnEnabled()) {
30664                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
30665                            }
30666    
30667                            throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
30668                                    primaryKey);
30669                    }
30670    
30671                    return journalArticle;
30672            }
30673    
30674            /**
30675             * Returns the journal article with the primary key or throws a {@link com.liferay.portlet.journal.NoSuchArticleException} if it could not be found.
30676             *
30677             * @param id the primary key of the journal article
30678             * @return the journal article
30679             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
30680             * @throws SystemException if a system exception occurred
30681             */
30682            @Override
30683            public JournalArticle findByPrimaryKey(long id)
30684                    throws NoSuchArticleException, SystemException {
30685                    return findByPrimaryKey((Serializable)id);
30686            }
30687    
30688            /**
30689             * Returns the journal article with the primary key or returns <code>null</code> if it could not be found.
30690             *
30691             * @param primaryKey the primary key of the journal article
30692             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
30693             * @throws SystemException if a system exception occurred
30694             */
30695            @Override
30696            public JournalArticle fetchByPrimaryKey(Serializable primaryKey)
30697                    throws SystemException {
30698                    JournalArticle journalArticle = (JournalArticle)EntityCacheUtil.getResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
30699                                    JournalArticleImpl.class, primaryKey);
30700    
30701                    if (journalArticle == _nullJournalArticle) {
30702                            return null;
30703                    }
30704    
30705                    if (journalArticle == null) {
30706                            Session session = null;
30707    
30708                            try {
30709                                    session = openSession();
30710    
30711                                    journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
30712                                                    primaryKey);
30713    
30714                                    if (journalArticle != null) {
30715                                            cacheResult(journalArticle);
30716                                    }
30717                                    else {
30718                                            EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
30719                                                    JournalArticleImpl.class, primaryKey,
30720                                                    _nullJournalArticle);
30721                                    }
30722                            }
30723                            catch (Exception e) {
30724                                    EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
30725                                            JournalArticleImpl.class, primaryKey);
30726    
30727                                    throw processException(e);
30728                            }
30729                            finally {
30730                                    closeSession(session);
30731                            }
30732                    }
30733    
30734                    return journalArticle;
30735            }
30736    
30737            /**
30738             * Returns the journal article with the primary key or returns <code>null</code> if it could not be found.
30739             *
30740             * @param id the primary key of the journal article
30741             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
30742             * @throws SystemException if a system exception occurred
30743             */
30744            @Override
30745            public JournalArticle fetchByPrimaryKey(long id) throws SystemException {
30746                    return fetchByPrimaryKey((Serializable)id);
30747            }
30748    
30749            /**
30750             * Returns all the journal articles.
30751             *
30752             * @return the journal articles
30753             * @throws SystemException if a system exception occurred
30754             */
30755            @Override
30756            public List<JournalArticle> findAll() throws SystemException {
30757                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
30758            }
30759    
30760            /**
30761             * Returns a range of all the journal articles.
30762             *
30763             * <p>
30764             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
30765             * </p>
30766             *
30767             * @param start the lower bound of the range of journal articles
30768             * @param end the upper bound of the range of journal articles (not inclusive)
30769             * @return the range of journal articles
30770             * @throws SystemException if a system exception occurred
30771             */
30772            @Override
30773            public List<JournalArticle> findAll(int start, int end)
30774                    throws SystemException {
30775                    return findAll(start, end, null);
30776            }
30777    
30778            /**
30779             * Returns an ordered range of all the journal articles.
30780             *
30781             * <p>
30782             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
30783             * </p>
30784             *
30785             * @param start the lower bound of the range of journal articles
30786             * @param end the upper bound of the range of journal articles (not inclusive)
30787             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
30788             * @return the ordered range of journal articles
30789             * @throws SystemException if a system exception occurred
30790             */
30791            @Override
30792            public List<JournalArticle> findAll(int start, int end,
30793                    OrderByComparator orderByComparator) throws SystemException {
30794                    boolean pagination = true;
30795                    FinderPath finderPath = null;
30796                    Object[] finderArgs = null;
30797    
30798                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
30799                                    (orderByComparator == null)) {
30800                            pagination = false;
30801                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
30802                            finderArgs = FINDER_ARGS_EMPTY;
30803                    }
30804                    else {
30805                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
30806                            finderArgs = new Object[] { start, end, orderByComparator };
30807                    }
30808    
30809                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
30810                                    finderArgs, this);
30811    
30812                    if (list == null) {
30813                            StringBundler query = null;
30814                            String sql = null;
30815    
30816                            if (orderByComparator != null) {
30817                                    query = new StringBundler(2 +
30818                                                    (orderByComparator.getOrderByFields().length * 3));
30819    
30820                                    query.append(_SQL_SELECT_JOURNALARTICLE);
30821    
30822                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
30823                                            orderByComparator);
30824    
30825                                    sql = query.toString();
30826                            }
30827                            else {
30828                                    sql = _SQL_SELECT_JOURNALARTICLE;
30829    
30830                                    if (pagination) {
30831                                            sql = sql.concat(JournalArticleModelImpl.ORDER_BY_JPQL);
30832                                    }
30833                            }
30834    
30835                            Session session = null;
30836    
30837                            try {
30838                                    session = openSession();
30839    
30840                                    Query q = session.createQuery(sql);
30841    
30842                                    if (!pagination) {
30843                                            list = (List<JournalArticle>)QueryUtil.list(q,
30844                                                            getDialect(), start, end, false);
30845    
30846                                            Collections.sort(list);
30847    
30848                                            list = new UnmodifiableList<JournalArticle>(list);
30849                                    }
30850                                    else {
30851                                            list = (List<JournalArticle>)QueryUtil.list(q,
30852                                                            getDialect(), start, end);
30853                                    }
30854    
30855                                    cacheResult(list);
30856    
30857                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
30858                            }
30859                            catch (Exception e) {
30860                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
30861    
30862                                    throw processException(e);
30863                            }
30864                            finally {
30865                                    closeSession(session);
30866                            }
30867                    }
30868    
30869                    return list;
30870            }
30871    
30872            /**
30873             * Removes all the journal articles from the database.
30874             *
30875             * @throws SystemException if a system exception occurred
30876             */
30877            @Override
30878            public void removeAll() throws SystemException {
30879                    for (JournalArticle journalArticle : findAll()) {
30880                            remove(journalArticle);
30881                    }
30882            }
30883    
30884            /**
30885             * Returns the number of journal articles.
30886             *
30887             * @return the number of journal articles
30888             * @throws SystemException if a system exception occurred
30889             */
30890            @Override
30891            public int countAll() throws SystemException {
30892                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
30893                                    FINDER_ARGS_EMPTY, this);
30894    
30895                    if (count == null) {
30896                            Session session = null;
30897    
30898                            try {
30899                                    session = openSession();
30900    
30901                                    Query q = session.createQuery(_SQL_COUNT_JOURNALARTICLE);
30902    
30903                                    count = (Long)q.uniqueResult();
30904    
30905                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
30906                                            FINDER_ARGS_EMPTY, count);
30907                            }
30908                            catch (Exception e) {
30909                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
30910                                            FINDER_ARGS_EMPTY);
30911    
30912                                    throw processException(e);
30913                            }
30914                            finally {
30915                                    closeSession(session);
30916                            }
30917                    }
30918    
30919                    return count.intValue();
30920            }
30921    
30922            @Override
30923            protected Set<String> getBadColumnNames() {
30924                    return _badColumnNames;
30925            }
30926    
30927            /**
30928             * Initializes the journal article persistence.
30929             */
30930            public void afterPropertiesSet() {
30931                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
30932                                            com.liferay.portal.util.PropsUtil.get(
30933                                                    "value.object.listener.com.liferay.portlet.journal.model.JournalArticle")));
30934    
30935                    if (listenerClassNames.length > 0) {
30936                            try {
30937                                    List<ModelListener<JournalArticle>> listenersList = new ArrayList<ModelListener<JournalArticle>>();
30938    
30939                                    for (String listenerClassName : listenerClassNames) {
30940                                            listenersList.add((ModelListener<JournalArticle>)InstanceFactory.newInstance(
30941                                                            getClassLoader(), listenerClassName));
30942                                    }
30943    
30944                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
30945                            }
30946                            catch (Exception e) {
30947                                    _log.error(e);
30948                            }
30949                    }
30950            }
30951    
30952            public void destroy() {
30953                    EntityCacheUtil.removeCache(JournalArticleImpl.class.getName());
30954                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
30955                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
30956                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
30957            }
30958    
30959            private static final String _SQL_SELECT_JOURNALARTICLE = "SELECT journalArticle FROM JournalArticle journalArticle";
30960            private static final String _SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT journalArticle FROM JournalArticle journalArticle WHERE ";
30961            private static final String _SQL_COUNT_JOURNALARTICLE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle";
30962            private static final String _SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle WHERE ";
30963            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "journalArticle.resourcePrimKey";
30964            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT DISTINCT {journalArticle.*} FROM JournalArticle journalArticle WHERE ";
30965            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1 =
30966                    "SELECT {JournalArticle.*} FROM (SELECT DISTINCT journalArticle.id_ FROM JournalArticle journalArticle WHERE ";
30967            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2 =
30968                    ") TEMP_TABLE INNER JOIN JournalArticle ON TEMP_TABLE.id_ = JournalArticle.id_";
30969            private static final String _FILTER_SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(DISTINCT journalArticle.id_) AS COUNT_VALUE FROM JournalArticle journalArticle WHERE ";
30970            private static final String _FILTER_ENTITY_ALIAS = "journalArticle";
30971            private static final String _FILTER_ENTITY_TABLE = "JournalArticle";
30972            private static final String _ORDER_BY_ENTITY_ALIAS = "journalArticle.";
30973            private static final String _ORDER_BY_ENTITY_TABLE = "JournalArticle.";
30974            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalArticle exists with the primary key ";
30975            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalArticle exists with the key {";
30976            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
30977            private static Log _log = LogFactoryUtil.getLog(JournalArticlePersistenceImpl.class);
30978            private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
30979                                    "uuid", "id", "type"
30980                            });
30981            private static JournalArticle _nullJournalArticle = new JournalArticleImpl() {
30982                            @Override
30983                            public Object clone() {
30984                                    return this;
30985                            }
30986    
30987                            @Override
30988                            public CacheModel<JournalArticle> toCacheModel() {
30989                                    return _nullJournalArticleCacheModel;
30990                            }
30991                    };
30992    
30993            private static CacheModel<JournalArticle> _nullJournalArticleCacheModel = new CacheModel<JournalArticle>() {
30994                            @Override
30995                            public JournalArticle toEntityModel() {
30996                                    return _nullJournalArticle;
30997                            }
30998                    };
30999    }